Ellen Heijmans
New member
- Joined
- Feb 1, 2024
- Messages
- 2
- Programming Experience
- 10+
I'm trying to create code in C# for accessing Google Calendar.
In console.cloud.google.com I've enabled the API, added users en added the scopes shown in the image below.
In my web application I've run Install-Package Google.Apis.Calendar.v3.
In code, the following scopes are added
I've code to create the credentials.
So far it works. I can an access token back and a refresh token. But if I try to do this
I get the following error:
Can anyone help me with this?
In console.cloud.google.com I've enabled the API, added users en added the scopes shown in the image below.
In my web application I've run Install-Package Google.Apis.Calendar.v3.
In code, the following scopes are added
C#:
String[] SCOPES = new String[] {
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/calendar",
"https://www.googleapis.com/auth/calendar.events",
};
C#:
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(ASPxUploadControl1.UploadedFiles[0].FileContent).Secrets,
SCOPES,
UserId,
CancellationToken.None,
new FileDataStore(fileName, true)).Result;
return credential;
C#:
CalendarList calendarList = this.service.CalendarList.List().Execute();
Code:
Google.GoogleApiException: 'The service calendar has thrown an exception. HttpStatusCode is Forbidden. Request had insufficient authentication scopes.'
Error {Google.Apis.Requests.RequestError
Request had insufficient authentication scopes. [403]
Errors [
Message[Insufficient Permission] Location[ - ] Reason[insufficientPermissions] Domain[global]
]
} Google.Apis.Requests.RequestError
Last edited by a moderator: