GoogleAuthUtil.getToken要求它的第二个参数是帐户对象,但是当您使用Google SignIn连接时,结果中的结果是GoogleSignInAccount - 这不是一回事.有没有办法将GoogleSignInAccount转换为Account对象?
private void handleSignInResult(GoogleSignInResult result) {
if (result.isSuccess()) {
googleSignInAccount = result.getSignInAccount();
}
}
Run Code Online (Sandbox Code Playgroud)
然后:
authToken = GoogleAuthUtil.getToken(context, [need an account here], scope);
Run Code Online (Sandbox Code Playgroud)
我知道我可以通过显示accountpicker来获取电子邮件地址,我也可以从google登录结果中获取电子邮件地址 - 但我看不到获取整个帐户对象的方法.
android google-authentication google-signin googlesigninaccount oauth2
我已阅读这些文件:
https://cloud.google.com/docs/authentication/getting-started?hl=ru#auth-cloud-implicit-java
https://cloud.google.com/storage/docs/reference/libraries?hl=ru
https://developers.google.com/identity/protocols/OAuth2ServiceAccount#callinganapi
我已存储服务帐户的 google-secrets.json 凭据。但是我不明白如何发送带有凭据的请求来获取身份验证令牌或 api 密钥。
只有已发布的库可以执行此操作。
如何在 Postman 中设置 HTTPS 身份验证?
google-api google-authentication google-oauth service-accounts postman
谷歌最近在这里宣布了一种新的用户登录方式。
\nhttps://developers.google.com/identity/gsi/web?hl=en
\n在本教程中,按钮是通过添加 HTML 代码或 JavaScript 创建的。
\n看起来像
\n\n但由于按钮都是在新的 Iframe 中创建和渲染的,因此我可以\xe2\x80\x99t 根据需要自定义按钮样式。
\n有什么方法可以改变以前提供的按钮样式吗?
\n以前,我用过
\nwindow.gapi.load(\'auth2\', () => {\n const auth2 = window.gapi.auth2.init(options);\n auth2.attachClickHandler(\n idButtonRef.current,\n {},\n onSuccessCallback,\n onFailCallback,\n );\n });\nRun Code Online (Sandbox Code Playgroud)\nidButtonRef.current是按钮,我所需要的只是附加按钮和事件监听器,如上面的代码所示。所以我能够创建我想要的按钮样式。
有没有办法通过谷歌用户签名的新方式来做到这一点?
\n我正在使用Firebase来处理我的网站上的Google OAuth登录信息.有谁知道如何限制有权访问该应用程序的用户?例如,我只想要x@gmail.com,y @ gmail.com和z@gmail.com才能成功通过谷歌登录我的应用程序.
我不确定这是Firebase还是Google问题,但是我们非常感谢任何帮助.
<html>
<head>
<meta name="google-signin-client_id" content="MY_CLIENT_ID.apps.googleusercontent.com" />
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script type="text/javascript">
function onSignIn(googleUser) {
console.log("Succesfully Singed in!!!");
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
通过上面我可以看到一个谷歌登录按钮打开一个弹出窗口接受凭证并签到我.但我希望登录成功时触发onSignIn方法,这是不会发生的.有没有人对此有任何指示?
通过safari,chrome和firefox浏览器在osx上的apache服务器上试用它
主要用例是使用IPython作为我自己的Google帐户的CLI.我真正追求的是在启动IPython shell和实际发出针对API的有用调用之间的大小调整.
使用Google API进行身份验证的文档侧重于设置其他用户将用于访问其数据的应用程序.这导致了一个涉及浏览器的冗长的Oauth舞蹈,以便允许其他用户在不损害其凭证的情况下进行身份验证.但是,我不介意与自己分享我的私人凭证.我不打算分享代码.如果我确实共享了代码,我会使用类似的dotenv方法将凭据与代码分开.
Twitter为开发人员提供了第二组凭据,允许开发人员访问自己的帐户进行测试.因此,可以通过仅提供凭证集来以编程方式访问自己的帐户:允许调用API的开发人员凭证以及授予对开发人员自己的数据的访问权的其他凭证.对于例如:
from twitter import *
t = Twitter(
auth=OAuth(token, token_key, con_secret, con_secret_key))
# Get your "home" timeline
t.statuses.home_timeline()
# Update your status
t.statuses.update(
status="Tweeting from Python")
Run Code Online (Sandbox Code Playgroud)
con_secret*开发人员凭据和token*帐户访问凭据在哪里?
举个例子,从我自己的Youtube播放列表中检索内容的最简单的程序是什么?
我可以认为Python无头浏览器库可以给我我需要的东西.我已经在SE Software Recommendations上提出了相关问题 https://softwarerecs.stackexchange.com/questions/35744/python-headless-browser-library-for-oauth2-authentication-from-ipython-console
google-api google-authentication headless-browser google-oauth google-api-python-client
我的前端应用程序使用gmail帐户进行身份验证.
我在身份验证成功后检索id_token,并将其作为授权标头发送为承载令牌.
授权承载token_id
在nodejs服务器端,我调用以下方法来验证令牌.
exports.verifyUser = function(req, res, next) {
var GoogleAuth = require('google-auth-library');
var auth = new GoogleAuth();
var client = new auth.OAuth2(config.passport.google.clientID, config.passport.google.clientSecret, config.passport.google.callbackURL);
// check header or url parameters or post parameters for token
var token = "";
var tokenHeader = req.headers["authorization"];
var items = tokenHeader.split(/[ ]+/);
if (items.length > 1 && items[0].trim().toLowerCase() == "bearer") {
token = items[1];
}
if (token) { …Run Code Online (Sandbox Code Playgroud) 我正在使用Google云平台,我必须使用java非Web应用程序访问云功能,例如我尝试使用Google云存储JSON API从Google云存储中存储和检索对象.
在访问那些我需要验证我的应用程序之前,我发现授权API具有授权访问权限.
当我试图从Google云平台获取凭据时,我最终选择了三种凭据
我浏览了GCP文档,但没有获得区分其中的明确信息,我对GCP几乎是新手,所以请您使用示例Java程序分享解释这些凭据类型的任何信息或博客链接,以显示如何使用Google云客户端库 API.
google-authentication google-cloud-storage google-cloud-platform
我一直试图从谷歌api使用谷歌客户端"代码"从谷歌客户端返回刷新令牌.它返回我发送到服务器端的代码.现在从服务器端我发送代码以使用google-api-php-client通过此调用获取刷新令牌和访问令牌:
https://www.googleapis.com/oauth2/v4/token
Run Code Online (Sandbox Code Playgroud)
虽然我使用谷歌操场上相同的代码我也得到了刷新令牌的响应,但我没有从我自己的服务器得到它..这是代码
public function getRefreshToken($code)
{
$client = new Google_Client();
$client->setClientId(config('services.google.client_id'));
$client->setClientSecret(config('services.google.client_secret'));
$client->setRedirectUri('postmessage');
$client->setScopes(config('services.google.scopes'));
$client->setAccessType("offline");
$client->setApprovalPrompt("force");
dd($client->authenticate($code));
dd($client->getRefreshToken());
return ;
}
Run Code Online (Sandbox Code Playgroud)
我已经将访问类型设置为离线,如某些答案中所述,但我仍然使用刷新令牌获得响应.这是响应
access_token :"xxxxxxxxxxxxxxxxxxxxxx"
created:1510242052
expires_in:3598
id_token:"xxxxxxxx"
token_type:"Bearer"
Run Code Online (Sandbox Code Playgroud) javascript php google-authentication google-api-php-client google-oauth2
我正在使用 Google 登录屏幕和 swiftUI,但我一直在我的日志中收到一堆我不太理解的消息 - 现在我可以使用这些日志,但我遇到的问题是我可以不要多次调用同一个函数...
import SwiftUI
import GoogleSignIn
class GoogleStuff: UIViewController, GIDSignInDelegate, ObservableObject {
var googleSignIn = GIDSignIn.sharedInstance()
var googleId = ""
var googleIdToken = ""
var googleFirstName = ""
var googleLastName = ""
var googleEmail = ""
var googleProfileURL = ""
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
guard user != nil else {
print("Uh oh. The user cancelled the Google login.")
return
}
print("TOKEN => \(user.authentication.idToken!)")
}
func sign(_ signIn: GIDSignIn!, didDisconnectWith …Run Code Online (Sandbox Code Playgroud)