Currently, I am trying to use Google Calendar's API to create a program that allows me to add stuff to my calendar, the only problem is that I don't know how to add a scope to my program. Google tells me I have to use "https://www.googleapis.com/auth/calendar" as a scope, how do I use this?
Understanding how scopes works requires that you understand a bit about how Oauth2 works.
Oauth2 is a form of authentication where by an application requests permission to access some data from a user by displaying a consent form. This consent form is populated by scopes which the application defines as the scope of access that it needs in order to run.
The Google authentication server supports a large number of scopes scopes they are split up by the API in which they are intended to access.
The Google Calendar API supports the follwing scopes. scopes
Assume that you are using the Google API Java client library your code should already be controlling the scopes you are sending. Look for the section that says CalendarScopes
.
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
httpTransport, JSON_FACTORY, clientSecrets,
Collections.singleton(CalendarScopes.ALL)).setDataStoreFactory(
dataStoreFactory).build();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With