Answer the question
In order to leave comments, you need to log in
Why is the Google API throwing a 403 error code when all permissions are requested and displayed in the access key?
I'm trying to write an application that could add Events to Google Calendar. The documentation says that for this it is necessary that access rights be granted during authorization
https://www.googleapis.com/auth/calendar , https://www.googleapis.com/auth/calendar.events
spring.security.oauth2.client.registration.google.client-id=****
spring.security.oauth2.client.registration.google.client-secret=****
spring.security.oauth2.client.registration.google.scope=profile,email,https://www.googleapis.com/auth/calendar,https://www.googleapis.com/auth/calendar.events
private OAuth2AuthorizedClient loadClientInfo(OAuth2AuthenticationToken authentication) throws Exception {
try {
OAuth2AuthorizedClient client = authorizedClientService
.loadAuthorizedClient(
authentication.getAuthorizedClientRegistrationId(),
authentication.getName());
return client;
} catch (Exception e) {
throw new Exception(e.getMessage());
}
}
GoogleCredential credential = new GoogleCredential().setAccessToken(tokenValue);
Calendar service = new Calendar.Builder(httpTransport, JSON_FACTORY, credential)
.setApplicationName(APPLICATION_NAME).build();
// Создание события
return service.events().insert(calendarId, event).execute();
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"errors": [
{
"message": "The request is missing a valid API key.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}
Answer the question
In order to leave comments, you need to log in
Did you translate the error? Or read? Written is not a working API Key
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question