Why is Google Calendar API (oauth2) responding with 'Insufficient Permission'?

元气小坏坏 提交于 2019-12-28 03:01:28

问题


I'm doing a get request to the following URL (with {id} replaced with the id from the web interface):

https://www.googleapis.com/calendar/v3/calendars/{id}

A few assertions:

  1. The Authorize header is being correctly set with a valid access token (the token works fine for the Analytics API)

  2. I've set the following scope for oauth2, which shows up correctly:

    https://www.googleapis.com/auth/calendar
    
  3. The token doesn't appear to have expired; it works for the Analytics API.

    { "error": { "errors": [ { "domain": "global", "reason": "insufficientPermissions", "message": "Insufficient Permission" } ], "code": 403, "message": "Insufficient Permission" } }
    

回答1:


To fix, I revoked access to the app at https://accounts.google.com/IssuedAuthSubTokens and retried after which, I was able to access the API correctly.

Despite having the scope in the list, and the scope showing up on Google's OAuth2 grant page, the additional scope wasn't granted.




回答2:


I would double-check the scope is included - I've seen that exact message when I've requested the wrong scope. Visiting https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=xxxxxx is a good way to verify.

Assuming that checks out, make sure that the user that you have the access token for has permission to view the calendar that you're trying to access. "Gears" icon -> "Settings" -> "Calendars" -> (select calendar) -> "Share this calendar"




回答3:


Add scope for calendar visit calendar api and check access configuration

https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.readonly



回答4:


I had to include the Google Plus scope in order to have sufficent permission to access a calendar:

So my scope ended up looking like this:

'https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.readonly', 'https://www.googleapis.com/auth/plus.login'




回答5:


I have had to delete permissions to my application and then back to give permissions in https://security.google.com/settings/security/permissions




回答6:


I had the same issue while I was trying to add an event in my google calendar. How I finally fixed this :

  • delete my file 'credentials.json'
  • launch a Python program which looks like the Google's quickstart program with written in " SCOPES = 'https://www.googleapis.com/auth/calendar' ". This program was the only solution that worked for me. Launch my django command to call my real work did not work for me. But this fixed my permission problem.

Then, it opens your browser and google asks your permission to manage your calendar and create a new 'credentials.json' in your repertory.




回答7:


I also face same issue when add or edit event. And after some googling, I found that, one scope will give you all permission -

https://www.googleapis.com/auth/calendar


来源:https://stackoverflow.com/questions/16970917/why-is-google-calendar-api-oauth2-responding-with-insufficient-permission

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