OAuth 2 authentication in Chrome extension using Google API Client Libriary -


I am trying to create a Chrome extension that uses Google Drive which uses OAuth 2 authentication using Google APIs. Requested client libraries mine extension for javascript was already registered in Google Developer Console.

manifest.json

  "background": {"page": "background.html"},   

background.html

  & gt; Script type = "text / javascript" src = "jquery-1.10.2.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "https://apis.google.com/js/client.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "google_auth / initiation.js" & gt; & Lt; / Script & gt;   

initiation.js

  var CLIENT_ID = 'MY_CLIENT_ID'; Var SCOPES = 'https://www.googleapis.com/auth/drive.file'; JQuery (window) .load (function () {gapi.auth.authorize ({client_id: CLIENT_ID, scope: scope, instant: false}, function (authResult) {if (authResult & amp; authResult.error) { The window! .lert ('Auth was successful!');} And (window.alert ('Auth was not successful');}}})}}   

when the extension was loaded Or reload in the browser, a popup appears and I receive a response message from Google:

???? is an error. Same.

Error: invalid_client < / P>

Applications: My Extension

Actually, I'm thinking that my Choosing Google API Library Library for ROM Extensions is right and there is nothing missing in my implementation.

I do not have enough reputation to comment, but if your initiation.js literally you should change 'MY_CLIENT_ID' and customer ID that you received when Google registered with your application from here CLIENT_ID

It looks like this: 858545004388-tlfkq1hfdbuiductlb0qdvjds4s949gt.apps.googleusercontent.com

This is the error: invalid_client is telling you.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -