问题标签 [google-oauth-java-client]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
802 浏览

google-plus - 谷歌得到电子邮件适当的范围

google 上的很多文档都谈到了email替换https://www.googleapis.com/auth/userinfo.email, 与端点的范围https://www.googleapis.com/userinfo/v2/me。在此处找到文档https://developers.google.com/+/api/oauth#email

然而,还有更多的文档表明,即使是被替换为有利于 plus api 和端点和people.get端点的文档。在此处找到文档https://developers.google.com/+/api/auth-migration#email

我有一个应用程序需要请求用户电子邮件进行身份验证并验证他们是否安装了我们的应用程序。一个奖励是当我尝试将email范围添加到开发人员控制台或在我的应用程序中使用它时,它告诉我email不是有效范围。
我的问题是需要在我的应用程序和谷歌开发者控制台中应用的正确范围是什么?需要确保这一点,因为 Google Apps Marketplace V2 有关于提示用户的规则。

0 投票
3 回答
335 浏览

google-api - Google API Oauth 已安装应用程序

我正在使用 google oauth 2 进行身份验证。(已安装的应用程序)

现在,当用户允许在用户同意屏幕中访问时,我如何从重定向 uri 中检索身份验证代码,而无需用户参与剪切和复制粘贴身份验证代码。如何从标题栏中读取授权码?

0 投票
1 回答
134 浏览

java - 使用 Google 对用户进行身份验证

我很难思考如何在我的 REST 服务中对用户进行身份验证。我计划使用 Google 登录(即在 Android 上)。我不太清楚如何在我的服务器上对用户进行身份验证。我不想获得任何授权(除了验证用户的身份),我想做的就是当我收到请求时,验证用户是他(或她)所说的那个人。

我的理解是用户将登录,从 Google 获取某种令牌,然后将该令牌连同他的请求一起发送到我的服务器,我将使用该服务器来验证他的身份。但是,根据我的阅读,用户将他们的请求编码为 JWT(json Web 令牌),然后我将使用它来验证他们的身份,而无需直接与 Google 服务器对话。我理解正确吗?

在 Google 的文档中,它说

如果您不需要离线访问,您可以检索访问令牌并通过安全连接将其发送到您的服务器。您可以直接使用 GoogleAuthUtil.getToken() 获取访问令牌,方法是指定范围而不指定服务器的 OAuth 2.0 客户端 ID。

但它没有说明服务器应该如何处理令牌。

0 投票
0 回答
632 浏览

google-app-engine - Google OAuth2 迁移和 App Engine 用户服务

语境

我正在将用 Java 编写的 Google App Engine 应用程序从使用 OpenId/OAuth1 迁移到 OAuth2。我已经让 OAuth2 流程正常工作,并且能够为用户正确检索/存储令牌。

问题

应用程序中现有的身份验证逻辑较为复杂,并利用 Google App Engine SDK 中的 UserService 类实现各种功能,例如 createLoginUrl()、isLoggedIn()、getCurrentUser()、getIsAdmin() 和 getEntry()。

我在Google 文档博客和 SO 上看到了各种帖子,其中给出了 UserService 与 OAuth2 一起使用的示例。我还看到各种帖子说 UserService 不应该使用,因为它基于 OpenId。我无法从 Google 找到任何官方文档,说明如何最好地从使用 UserService 功能进行迁移(例如,我是否应该在 Users/Directory API 之上创建自己的层来模拟 UserService 功能?)。

我主要担心的是,当 Google 完全弃用并删除对 OAuth1/OpenId 的支持时,UserService 将停止工作,因此需要在决定实施方法之前解决这个问题。

有人对如何处理这种情况有任何官方指导吗?提前致谢。

0 投票
1 回答
222 浏览

java - 使用凭据 - google drive sdk + java

我需要使用 Google Drive SDK 将文件上传到 Google Drive 光盘。我有简单的课程来做到这一点:

它正在工作,但用户必须从浏览器中复制代码并将其粘贴到控制台中。有没有可能在不从浏览器复制代码的情况下制作它?我发现了这样的东西(来自:https ://developers.google.com/drive/web/service-accounts )

但我得到了例外:

我无法理解并找到问题所在。

我真的很惊讶,使用凭证是如此困难,而且我不能编写非常简单的应用程序。

0 投票
1 回答
767 浏览

oauth-2.0 - DFA Reporting: Unable to fetch profiles using Service Account

I am developing a piece of code which can create and download reports using Google DFA Reporting API's.

I am able to do the same using Client Id and Client Secret, which is generated using Install-App (native Application) account, but with this type of account, it always open a browser for first time and then only it authenticates the future request.

On further reading, I came across the service account. I then created a new Service Account and downloaded p12 key. I am now able to build credential object with the help of p12 and Email account (*******ccms@developer.gserviceaccount.com). I can confirm this as I am seeing access token in a credential object after calling credentials.refreshToken().

I then create an object of DFA Reporting using the above credential and trying to fetch profiles list, but I am getting the below error:

Please see my code below and let me know where I am going wrong:

PS: I am able to fetch all the profiles, if I use access token which is generated using client id and client secret provided by native application (installed apps) account.

Thanks, Hussain Bohra

0 投票
0 回答
120 浏览

google-oauth - 无法更新谷歌市场配置上的“电子邮件”和“个人资料”范围

在我的应用程序中,我创建了一个市场应用程序,它使用

' https://www.googleapis.com/auth/userinfo.email '
' https://www.googleapis.com/auth/userinfo.profile '

现在根据谷歌将关闭userinfo端点。我正在尝试将两个范围都更改为等效范围“电子邮件”和“个人资料”。现在,当我尝试使用新范围刷新用户令牌时。我得到以下错误

{
"error" : "access_denied",
"error_description" : "请求的客户端未授权。"
}

我正在使用下面的代码来刷新用户的令牌

new Builder().setTransport(NET_HTTP_TRANSPORT) .setJsonFactory(JACKSON_FACTORY) .setServiceAccountId(googleOAuthService.getServiceClientEmail()) .setServiceAccountScopes(googleOAuthService.getScopes()) .setServiceAccountUser(email) .setServiceAccountPrivateKeyFromP12File(keyFile);

我无法将范围更改为https://www.googleapis.com/auth/plus.me,因为它将再次显示同意屏幕。

我想我需要在谷歌项目市场 sdk 配置中添加“电子邮件”和“个人资料”范围,但它给了我错误,即给定范围无效。

任何人都请帮助我如何解决它。提前致谢

0 投票
1 回答
3030 浏览

javascript - Google OAuth 2.0“请求许可”网页未关闭(FF、Chrome)

我正在使用 Google OAuth 2.0 对已安装的桌面 Java 应用程序进行身份验证。我正在使用 Google OAuth 2.0 Java 客户端库。

当我拨打电话请求用户授权访问他们的 Google 日历时,“请求权限”网页按预期显示在默认浏览器中。用户点击取消或接受后,网页显示消息:

收到验证码。关闭...

在 Internet Explorer 中,网页随即关闭。但是,在 Firefox 和 Chrome 中,网页仍然打开。

有没有办法强制关闭网页(从我的 Java 程序)?

这是我正在使用的触发网页的代码(取自 Google 开发人员的 CalendarSample(http://samples.google-api-java-client.googlecode.com/hg-history/425c5ffc30178f21aea592bc989849ea7e3498fe/calendar-cmdline-sample/instructions .html):

0 投票
1 回答
205 浏览

google-calendar-api - 将企业 gmail 帐户的日历 API 访问权限授予第三方?

假设公司 A 设置了公司 gmail 帐户。

公司 B 需要通过谷歌日历 REST API 访问公司 A 用户的日历事件(主要是空闲繁忙时间)。

我看到这里描述的一些方法https://developers.google.com/google-apps/calendar/设置 api 访问。

但目前尚不清楚哪种方法是最好的方法。有人可以描述如何实现这一目标的高级概述吗?我熟悉谷歌日历 api 文档以及启用日历 REST API 所需的先决条件......目前尚不清楚如何将其应用于所描述的场景。

0 投票
0 回答
401 浏览

java - 从存储的 AccessToken 和 RefreshToken 创建新的 Credentials 对象

我正在关注 Google Drive SDK 文档的实现服务器端身份验证部分,如果留给读者作为练习,则在代码中呈现以下部分:

AuthorizationToken鉴于我们将和RefreshTokens存储为字符串,实际上如何做到这一点?