2

I am trying to create a Chrome Extension which would save some data to the user's Google Drive. I figured OAuth would be the best way to go about it. So I do the following in manifest.json:

"oauth2": {
    "client_id": "<my_client_id>",
    "scopes": ["https://www.googleapis.com/auth/drive"]
}

After that, I want to use the Google API for authentication in my background.js using gapi.auth.authorize etc. However even if I include https://apis.google.com/js/client.js in background scripts of manifest, it still can not find it. What am I doing wrong? Is there a better way to use OAuth?

datah4ck3r
  • 1,174
  • 1
  • 8
  • 19

1 Answers1

3

What am I doing wrong?

This is your question, basically. You are trying to include a remote script which is forbidden by the default CSP. This can be relaxed; see the question for more details.

Is there a better way to use OAuth?

Yes, chrome.identity API. You can take a look at a sample app provided by Google.

Community
  • 1
  • 1
Xan
  • 74,770
  • 16
  • 179
  • 206