Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 带有spring security 5和oauth2的日历客户端_Java_Reactjs_Google Calendar Api_Spring Security Oauth2 - Fatal编程技术网

Java 带有spring security 5和oauth2的日历客户端

Java 带有spring security 5和oauth2的日历客户端,java,reactjs,google-calendar-api,spring-security-oauth2,Java,Reactjs,Google Calendar Api,Spring Security Oauth2,我成功地用outh2配置了GoogleSpringSecurity5以连接到google。我有能力保存访问令牌。在我的应用程序的第一步中,我们不请求日历权限。我们不想等到以后再得到它们。我见过许多使用webClient、resttemplate的奇怪示例,这些示例已经被弃用 我正在寻找一种解决方案,在该解决方案中,我可以使用应用程序的access_令牌和refresh_令牌请求访问日历,然后我可以下载例如事件 我用的是reactjs。我希望它将我重定向到谷歌网站,给我权限,然后能够下载事件后,再

我成功地用outh2配置了GoogleSpringSecurity5以连接到google。我有能力保存访问令牌。在我的应用程序的第一步中,我们不请求日历权限。我们不想等到以后再得到它们。我见过许多使用webClient、resttemplate的奇怪示例,这些示例已经被弃用

我正在寻找一种解决方案,在该解决方案中,我可以使用应用程序的access_令牌和refresh_令牌请求访问日历,然后我可以下载例如事件

我用的是reactjs。我希望它将我重定向到谷歌网站,给我权限,然后能够下载事件后,再次点击首页

编辑: 答案是:

Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod());
        credential.setAccessToken("your token");
        credential.setRefreshToken("your refresh token");
        httpTransport = GoogleNetHttpTransport.newTrustedTransport();
        client = new com.google.api.services.calendar.Calendar.Builder(httpTransport, JSON_FACTORY, credential)
                .setApplicationName(APPLICATION_NAME).build();
Google支持,因此如果您使用新权限再次启动OAuth流,并且
include\u grated\u scopes
参数设置为true,您可以将新权限添加到现有授权中


或者,您可以使用托管解决方案来添加这种集成。它为您处理OAuth流(内置增量授权)以及刷新令牌,并与React进行本机集成。(披露:我在那里工作!)

因此,在需要检索事件之前,基本上不希望只包含必要的作用域?如果没有,你能提供更多关于你想要达到的目标的信息吗@DeluxxxI仅允许您在设置中连接日历并下载活动,而不是在您首次注册时@那么,正如下面提到的,在这种情况下,增量授权似乎是最好的决定。为什么这不是你的选择@德鲁克。我创造了这样的东西。我得到了带有示波器的令牌。在授予日历之后。我想更改页面并获取所有事件。没有一个问题需要授权。只有在另一侧,当您单击时,才显示我的事件。如何正确地初始化凭据?我存储acces令牌。com.google.api.services.calendar.calendar client=new com.google.api.services.calendar.calendar.Builder(httpTransport,JSON_工厂,凭证).setApplicationName(APPLICATION_NAME).build();但是如何初始化凭证来获取事件。我真的需要使用增量模式吗?我总是可以使用扩展的作用域列表启动新授权,对吗?@Alexey yes您可以手动跟踪您已请求的作用域,并在其上添加更多(不带此标志)。这是我们(Xkit)对没有这样标志的提供商采用的策略。