OAuth Token works for userInfo, but not for Google Calendar

Can someone tell me why I cannot use the same token to retrieve a list of users and calendars from Google?

I set the correct areas (I think):

  private static final String PLUS_ME_SCOPE = "https://www.googleapis.com/auth/plus.me";
  private static final String USER_INFO_PROFILE_SCOPE = "https://www.googleapis.com/auth/userinfo.profile";
  private static final String USER_INFO_EMAIL_SCOPE = "https://www.googleapis.com/auth/userinfo.email";
  private static final String GOOGLE_CALENDAR_SCOPE = "https://www.googleapis.com/auth/calendar";

To get user information, I use this URL: https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token= and for the calendars I use: https://www.googleapis.com/calendar / v3 / users / me / calendarList? minAccessRole = writer & key = .

In the user information, I get all the correct information, but for the calendar I get the error message 401: Login required.

What is wrong here?

0
source share
1 answer

Edit

https://www.googleapis.com/calendar/v3/users/me/calendarList?minAccessRole=writer&key=

to

https://www.googleapis.com/calendar/v3/users/me/calendarList?minAccessRole=writer&access_token=

Just that simple;)

UPDATE:

Also note that it is not recommended to specify an access token as a request parameter :

Due to the security vulnerabilities associated with the URI method (see Section 5), including the high probability that the URL containing the access token will be registered, it SHOULD NOT be used if it is not possible to transfer the access token to the Authorization request header field or the body of an HTTP request object.

+1
source

Source: https://habr.com/ru/post/1527809/


All Articles