简体   繁体   中英

401 ( Unauthorised ) error when using jQuery's $.get and GMail API

I'm trying to run jQuery's $.get after having a user log in with the G+ API with javascript, but am getting a 401 ( unauthorised ) error in the browser console.

Here is the format of the url I am requesting: https://www.googleapis.com/gmail/v1/users/myusername%40gmail.com/messages?key=%7Bmyborwserapikey%7D

I've also tried https://www.googleapis.com/gmail/v1/users/me/messages?key=%7Bmyborwserapikey%7D

both are returning the 401 error after logging in.

Each request to the Gmail API requires an access token, so an API key will not be enough.

While the user may have logged in with the G+ API that does not by itself give your app authorized access to the user's Gmail.

Check here for more details on getting access to the Gmail API: https://developers.google.com/gmail/api/overview#auth_and_the_gmail_api

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM