I have generated client_id from google developer console. Is it necessary to load a client library and call the api using keyword gapi as shown in the official site here? Since, i can get the authentication token using chrome.identity namespace, can't i use this token to make simple XMLHttpRequest to gmail apis?
Asked
Active
Viewed 471 times
0
-
Yes, you can use the token to access the API through XMLHttpRequest's without having to download the Google API client library. You have the docs [here](https://developers.google.com/gmail/api/v1/reference/) – Iván Nokonoko Sep 17 '17 at 07:35
-
How can i set other query parameters as described [here](https://developers.google.com/gmail/api/v1/reference/users/messages/list).If i need to fetch only email messages sent by certain user, then i need to set 'q' parameter most probably. Will settings these query parameters in a query string of XMLHttpRequest will work? – Mohit Sep 17 '17 at 11:12
-
Yes, it will work using the 'q' parameter or any of the other query parameters. – Iván Nokonoko Sep 17 '17 at 11:46
-
In addition to @Iván Nokonoko's comments, you may follow this [tutorial](http://developer.streak.com/2014/10/how-to-use-gmail-api-in-chrome-extension.html) on how to use the Gmail API in a Chrome extension. In this [sample](https://gist.github.com/omarstreak/7908035c91927abfef59), there is an included `background.js` file that already does the necessary work to authorize and load the Gmail client library. You simply need to replace the `clientID` with the one you have generated. Here's another SO post which might also help: https://stackoverflow.com/questions/23174710. – abielita Sep 17 '17 at 18:41
-
When i used chrome.identity.getAuthToken, token is undefined and gives an error message 'Authorization page could not be loaded' after i select a user from consent screen. To make my extension id constant i have uploaded my extension to chrome web store (have not published yet). Then i generated a client_id from google developer console and included in my manifest file, provided necessary permissions. However i am not able to generate token. What am i missing? Is it necessary to publish the extension to make identity work? – Mohit Sep 18 '17 at 06:45