简体   繁体   English

如何使用 Google 日历范围?

[英]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 Calendar 的 API 创建一个程序,该程序允许我向日历添加内容,唯一的问题是我不知道如何向我的程序添加范围。 Google tells me I have to use "https://www.googleapis.com/auth/calendar" as a scope, how do I use this? Google 告诉我必须使用“https://www.googleapis.com/auth/calendar”作为范围,我该如何使用?

Understanding how scopes works requires that you understand a bit about how Oauth2 works.了解作用域的工作原理需要您对 Oauth2 的工作原理有所了解。

Oauth2 is a form of authentication where by an application requests permission to access some data from a user by displaying a consent form. Oauth2 是一种身份验证形式,其中应用程序通过显示同意书来请求用户访问某些数据的权限。 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. Google 身份验证服务器支持大量的作用域 范围,它们由它们打算访问的 API 拆分。

The Google Calendar API supports the follwing scopes. Google Calendar API 支持以下范围。 scopes 范围

在此处输入图片说明

Assume that you are using the Google API Java client library your code should already be controlling the scopes you are sending.假设您正在使用Google API Java 客户端库,您的代码应该已经控制了您发送的范围。 Look for the section that says CalendarScopes .查找显示CalendarScopes的部分。

 GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
            httpTransport, JSON_FACTORY, clientSecrets,
            Collections.singleton(CalendarScopes.ALL)).setDataStoreFactory(
            dataStoreFactory).build();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM