Implementing Google+ one-time code flow authentication from chrome extension

自古美人都是妖i 提交于 2019-12-23 04:08:08

问题


I am trying to implement a Google+ sign in option as part of a chrome extension using the one-time code flow as described here.

While making a request using the javascript Google API package a popup opens with an "origin_mismatch" error. This is obviously since I need to add my origin to the relevant Client Id on the Google API console.

My origin is : chrome-extension://<my extension id> however when trying to add that on the API console I get an error saying "Invalid URI: chrome-extension://..." which probably means this scheme is not supported.

Any idea what I can do instead?


回答1:


I've faced the same problem. I think Google has changed the validation for javascript origins and doesn't allow origins from chrome-extension any more. Google gives you the Chrome Identity API instead (https://developer.chrome.com/apps/app_identity)

But there is a workaround. If you already have at least one chrome-extension://[ext_id] origin in your client ID and you have for example the older version of your extension with this extension ID, you can:

  • install this extension
  • go to C:\Users\username\AppData\Local\Google\Chrome\User Data\Default\Extensions (for windows)
  • find your extension there and open the manifest.json
  • copy the line "key":"[your_key]" and paste it into your developed manifest

and after next build you should get the extension with the same id as it was in the working one. Also it won't change any more.



来源:https://stackoverflow.com/questions/21830139/implementing-google-one-time-code-flow-authentication-from-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!