使用Google API登录时需要帮助.我使用他们的API在我的网站上通过Google登录按钮:
(function() {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();)
Run Code Online (Sandbox Code Playgroud)
但是,当我刷新页面或转到另一个页面时,它会显示登录按钮,我需要再次登录.
即使刷新页面后,如何在首次登录后"记住"用户?
使用Facebook,它很简单,只需使用:
FB.getLoginStatus(updateStatusCallback));
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在寻找有关Google OAuth2 API中RFC7636(OAuth令牌交换的校对密钥)状态的具体信息.
Google公开了一个OAuth 2.0和OIDC提供商API,可以获取访问令牌.RFC7636中描述了一种建议的标准,用于在令牌交换中使用证明密钥,我们已经开始在与主要身份提供商的集成中使用.有些人接受证明密钥,有些人则忽略它; Google似乎意识到了这一点,但未能验证证明密钥.我还没有找到任何关于谷歌的提及.
具体而言,当遵循OAuth 2.0授权代码流与Google作为提供者时,我们生成一个随机数,使用SHA256对其进行哈希处理,对其进行base64 URL编码,然后将其传递给https://accounts.google.com/o/oauth2/v2/auth作为参数"code_challenge"和"code_challenge_method"按照规范.
端点接受参数并照常发出授权令牌.获取访问令牌时,我们使用code_verifier 调用https://www.googleapis.com/oauth2/v4/token ; 端点返回以下HTTP 400错误,表明存在一些代码验证者的意识:{"error":"invalid_grant","error_description":"缺少代码验证程序".}
developer.google.com/identity/protocols/OAuth2上的Google OAuth文档未提及任何这些参数; API操场不会扩展到使用OAuth2身份验证和令牌端点.任何见解将不胜感激.
我正在尝试遵循本指南:对已安装的应用程序使用OAuth 2.0
我通过了第一部分的确定,用户可以授权我的应用访问他们的Google云端硬盘。用户授予权限后,我已经成功检索了授权代码。
不幸的是,我陷入了第二部分:redirect_uri_mismatch在发送POST请求以将授权代码交换为访问令牌时,我一直遇到错误。
该指南说,我应该使用“您从开发人员控制台获得的重定向URI”。我从开发者控制台中的此链接下载了凭据:
其中包含具有以下属性的JSON:
"redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]
Run Code Online (Sandbox Code Playgroud)
我已经尝试了redirect_uri对每个选项的请求设置;我尝试将其设置为空字符串;我也尝试过完全缺少它。没用。
每次我遇到redirect_uri_mismatch错误。
我也尝试过从下载的凭证发布到此URL:
"token_uri":"https://accounts.google.com/o/oauth2/token"
Run Code Online (Sandbox Code Playgroud)
以及指南页面中的网址(https://www.googleapis.com//oauth2/v4/token),但是每次我遇到相同的错误时,
如何解决此错误并成功交换访问令牌的授权代码?
Fiddler的屏幕截图示例显示了我尝试的许多请求之一:
或原始HTTP请求示例:
POST https://accounts.google.com/o/oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: accounts.google.com
Content-Length: 253
Expect: 100-continue
Connection: Keep-Alive
client_id=175836713882-m783k1ksu2rc6vepq35j4o8hhpk94ndj.apps.googleusercontent.com&client_secret=A---removed-for-security---A&code=4---removed-for-security---E&grant_type=authorization_code&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob
Run Code Online (Sandbox Code Playgroud)
注意:我知道有很多关于此错误的已回答问题,这些错误与Web App身份验证流程之后的重定向URI的拼写错误有关,但这特别与已安装的应用程序流程有关。我在已安装的应用程序流中找不到与此错误消息相关的已回答问题
我想在android上获取与gmail帐户相关的个人资料图片.我已经使用帐户选择器意图在我的应用程序中选择/登录gmail(身份验证).我使用了以下代码
mCredential = GoogleAccountCredential.usingOAuth2(
getApplicationContext(), Arrays.asList(SCOPES))
.setBackOff(new ExponentialBackOff())
.setSelectedAccountName(settings.getString("PREF_ACCOUNT_NAME", null));
Run Code Online (Sandbox Code Playgroud)
在启动oAuth后,我最终得到以下结果方法
protected void onActivityResult(
int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case REQUEST_ACCOUNT_PICKER:
if (resultCode == RESULT_OK && data != null &&
data.getExtras() != null) {
String accountName =
data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
Log.e("ghfyg",""+accountName);
if (accountName != null) {
mCredential.setSelectedAccountName(accountName);
SharedPreferences settings =
AccountSync.this.getSharedPreferences("deep",Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putString("PREF_ACCOUNT_NAME", accountName);
editor.apply();
}
} else if (resultCode == RESULT_CANCELED) {
Toast.makeText(this,"Account unspecified.",Toast.LENGTH_SHORT).show();
}
break;
}
super.onActivityResult(requestCode, resultCode, data);
} …Run Code Online (Sandbox Code Playgroud) 根据Google OpenID 2.0迁移时间表,"OpenID 2.0标识符到OAuth 2.0标识符的映射将继续有效,直到2017年1月1日."
从文档中可以100%清楚这种转变将采取什么形式.请求范围:"openid"或openid.realm:"something"开始返回错误?或者旧的openid值是否会在响应中出现?在谷歌ID连接文档仍使用其例如ID连接的认证请求URI值.
有没有人更好地了解这将如何消失?我们的方法是放弃openid范围和openid.realm,但我们试图更好地确定更改的确切形式.
编辑:这是一个最小的可行项目
我正在尝试从服务器端流程的授权代码中获取Google的访问权限和刷新令牌.我在此处按照Google指南操作:https://developers.google.com/identity/sign-in/web/server-side-flow.
我使用的是护照和护照-google-authcode.
以下是节点应用的路由:
router.get('/auth/google_auth_code',
passport.authenticate('google_authcode', {
scope:
[
'https://www.googleapis.com/auth/calendar',
'profile',
'https://www.googleapis.com/auth/userinfo.email'
]
}),
function () {
res.end();
})
router.get('/auth/google_auth_code/callback',
passport.authenticate('google_authcode', {
failureRedirect: '/error'
}),
function (req, res) {
// do something with req.user
res.send('hello');
}
);
Run Code Online (Sandbox Code Playgroud)
这是此策略的护照配置.
passport.use('google_authcode', new GoogleAuthCodeStrategy({
clientID: 'my client id',
clientSecret: 'my secret',
callbackURL: '/auth/google_auth_code/callback',
// passReqToCallback: true
},
function (accessToken, refreshToken, rawResponse, profile, done) {
// unable to get here
}
));
Run Code Online (Sandbox Code Playgroud)
发出身份验证请求时,Google会响应以下错误:
{
"error" : …Run Code Online (Sandbox Code Playgroud) 我有一个Web应用程序,由具有各自URL的多个客户使用.
我们正在通过Google API将Google帐户与OAuth2集成.
现在,我们已经注册了一个由所有系统使用的项目/应用程序.
问题是如果在多个系统上连接了相同的帐户,则由于存在单个项目而会覆盖令牌.同样的事情,如果帐户与系统A断开连接并且它也连接在系统B上,则系统B停止工作,因为Google API项目/应用程序是相同的.
我想知道是否有一个解决方法,每个帐户有一个应用程序具有多个令牌/连接,或者唯一的方法是每个系统有一个项目,我需要以编程方式创建项目并相应地设置所有内容建立了一个新系统.
Our app underwent the google review process recently. We received a confirmation that the app has been approved and if we need to change it we'll have to undergo the review process again.
We tried to change the product logo URL after it was verified but in vain. It shows an error stating You do not have permission to perform this action.
There is a link to update form which does not have the product logo URL field. ( …
google-api google-oauth google-oauth2 google-developers-console
问题: 我正在使用Aws Cognito,使用google作为我的应用程序身份验证的外部联合身份:问题是当只有一个Google帐户登录时,它以最后一个用户身份登录。基本上看来,它根本无法完全注销用户。
这是发生了什么事:
我正在使用https://mydomain.auth.auth.us-east-1.amazoncognito.com/login上的cognito屏幕
使用提示:
我看到google本身有一种方法可以强迫用户使用'prompt':select_account选项选择一个帐户。但是我看不到在Cognito的任何地方指定此方法。
问题: -任何人都可以解决以上问题吗?我需要一种“始终”显示帐户选择的方法,以便他可以选择或使用其他帐户。
您是否尝试过从cognito注销端点? -是的,即使我将用户发送到cognito的注销端点(可能应该注销用户)之后,这种情况仍在发生。
我有Google-Apps-Marketplace应用,其中我正在使用"与Google集成"按钮来启动Google OAuth2流程.由于某些未知原因,该按钮今天消失,我收到错误404 - https://apis.google.com/marketplace/button
有人知道这是谷歌API中的临时问题,还是有些事情发生了变化,我需要更新我的应用程序?
我从4年前看到了关于按钮消失的类似问题,但他们在那里提到访问问题(错误403).帮助将不胜感激.
google-oauth2 ×10
google-api ×3
oauth-2.0 ×3
google-oauth ×2
android ×1
aws-cognito ×1
cognito ×1
google-apps ×1
google-login ×1
gsuite ×1
java ×1
javascript ×1
node.js ×1
oauth ×1
openid ×1
openid2 ×1