如何使用Google OAuth2和Java将GET请求发送到script.google.com网页? [英] How to send GET request with google OAuth2 and Java to script.google.com web page?

查看:66
本文介绍了如何使用Google OAuth2和Java将GET请求发送到script.google.com网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GET正在为我工​​作,但发送时会获得Google服务授权页面.我从Google阅读了指南,但仍然不了解如何正确使用凭据.

GET is working for me but I get google services authorization page when I send it. I read guides from google but still don't understand how to use Credentials right.

所有内容用于管理脚本文件本身,却一无所有与我的问题有关:/

This thing is for managing script files itself and have nothing to do with my problem :/

如果在Java中可能的话,将是体面的

Would be decent if it is possible in Java

推荐答案

登录google后,您将在带有Google代码的重定向页面上进行重定向.可以在Google私人用户控制台中设置重定向页面.当您获得Google代码时,可以使用代码通过GoogleAuthorizationCodeFlow获取jwt

After sign in google you will be redirected on redirect page with google code. Redirect page could be set in google private user console. When you will get google code you could use code for obtaining jwt with GoogleAuthorizationCodeFlow

例如

    GoogleAuthorizationCodeTokenRequest googleAuthorizationCodeTokenRequest = codeFlow.newTokenRequest(code)
        .setRedirectUri(redirectUrl);
    try {
        GoogleTokenResponse googleTokenResponse = googleAuthorizationCodeTokenRequest.execute();

    } catch (IOException e) {
        throw new ExternalAuthenticationException("Invalid google 'code' parameter (disposable)");
    }

这篇关于如何使用Google OAuth2和Java将GET请求发送到script.google.com网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆