Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use a Google Calendar scope?

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?

like image 783
Nam Avatar asked Nov 06 '22 04:11

Nam


1 Answers

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

enter image description here

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();
like image 196
DaImTo Avatar answered Nov 12 '22 13:11

DaImTo