以下代码/sf/answers/255440391/一直有效,直到最近谷歌更改了他们的安全策略时才崩溃.
我收到了谷歌的邮件
嗨xxx,有人刚尝试从不符合现代安全标准的应用登录您的Google帐户xxx@gmail.com.
我们强烈建议您使用Gmail等安全应用访问您的帐户.Google生产的所有应用均符合这些安全标准.另一方面,使用安全性较低的应用可能会使您的帐户容易受到攻击.学到更多.
Google停止了此次登录尝试,但您应该查看最近使用过的设备:
我查看了https://support.google.com/accounts/answer/6010255?hl=en-GB
我想知道,实现正确的登录尝试的方法是什么,以便继续通过Gmail SMTP发送电子邮件,用户端配置为0?
我想修改在Google API控制台中注册的用于Google+登录的我的捆绑ID.
对这个答案的问题告诉我该怎么做,但我没有看到Client id,并secret在API Access他在说什么.可能是因为Google API控制台已更改.
有谁知道如何编辑Google API控制台中Google+集成的当前注册的捆绑ID?
编辑: 我看不到客户端ID和秘密,因为它被某种方式删除了.我创建了一个新的.用现有的客户端ID替换.但仍然是同样的错误.
我正在尝试使该示例工作:https : //developers.google.com/analytics/devguides/config/mgmt/v3/quickstart/web-php#enable
我收到的错误是“错误:redirect_uri_mismatch”。
为了安装google api资源,我在以下命令中使用了composer:
php composer.phar require google/apiclient:^2.0.0@RC
Run Code Online (Sandbox Code Playgroud)
这将“ vendor”文件夹安装在我的根站点文件夹中。我的index.php和oauth2callback.php文件位于“ public_html”文件夹中。
这是我进入网站时出现的错误的屏幕截图:
奇怪的是,如果我导航到错误消息“访问......以更新授权的..”中包含的以上链接,则会收到以下错误消息:“ OAuth客户端不存在”
如果单击我唯一可用的客户端ID,则可以导航以查看URI,我还将在下面截屏:
如您所见,在“授权Javascript起源”下,我列出了http:// localhost,在“授权重定向URI”下,我的活动站点后面是“ oauthc2callback.php”文件扩展名。
我不明白如何摆脱我得到的错误。我尝试过替换URI并放入不同的JavaScript来源。
另外,由于最后一个屏幕截图的某种原因,它表示我没有编辑此OAuth客户端的权限,但是我可以进行编辑。
我为index.php提供的代码:
<?php
// Load the Google API PHP Client Library.
require_once '../vendor/autoload.php';
// Start a session to persist credentials.
session_start();
// Create the client object and set the authorization configuration
// from the client_secretes.json you downloaded from the developer console.
$client = new Google_Client();
$client->setAuthConfigFile('../config/client_secrets.json');
$client->addScope('https://www.googleapis.com/auth/analytics.readonly');
// If the user has already authorized this app …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 google Oauth 2 通过 google calendar API 对在 AWS EC2 上运行的 Web 服务器进行身份验证。
当我生成凭据时,我选择了“OAuth 客户端 ID”,然后选择“Web 应用程序”。对于我输入的授权重定向 URI:
http://ec2-XX-XX-XX-XXX.eu-west-1.compute.amazonaws.com (我已将 EC2 实例的 IP 清空)。我已经检查过这是我希望回调转到的正确 URL。
服务器日志中生成的链接的形式为:
当我点击链接时,出现错误“错误:redirect_uri_mismatch”。
我已经阅读了这个问题,并检查了我正在使用 HTTP 并且没有试用“/”
我怀疑生成的 URL 中不应包含“localhost”,但我已多次重置 client_secret.json,每次使用新的客户端密钥重新启动 tomcat 时,我仍然会获得与 localhost 的链接,但只是通过不同的端口。
在本地,我之前选择了“其他”凭据类型,并且没有提供授权重定向 URI 的选项。我确实在 EC2 实例上尝试过此操作,但这不会让我获得我想要的对重定向 URI 的控制并通过 localhost 发送重定向。
我有一个简单的客户端应用程序,使用react-google-login 和以下设置:
<GoogleLogin
clientId={config.CLIENT_ID}
scope={config.SCOPES.join(' ')}
buttonText="Login With Google"
onSuccess={response => onSignIn('google', response)}
onFailure={this.failure.bind(this)}
accessType="offline"
responseType="code"
/>
Run Code Online (Sandbox Code Playgroud)
它成功检索代码并将其发送到用 NodeJS 编写的后端服务器。
服务器端代码如下所示:
const { google } = require('googleapis');
const config = global.config;
const oauth2Client = new google.auth.OAuth2({
clientId: config.google.CLIENT_ID,
clientSecret: config.google.CLIENT_SECRET,
});
// code omitted for the sake of simplicity
var authCode = req.body.authCode; // the provided code by google
const { tokens } = await oauth2Client.getToken(authCode);
return tokens;
Run Code Online (Sandbox Code Playgroud)
当我运行代码时,它抛出错误:
{ error: 'invalid_request',
error_description: 'Missing parameter: redirect_uri' } },
code: '400' …Run Code Online (Sandbox Code Playgroud) oauth ×2
amazon-ec2 ×1
api ×1
email ×1
gmail ×1
google-oauth ×1
google-plus ×1
ios ×1
java ×1
node.js ×1
oauth-2.0 ×1
redirect ×1
security ×1
uri ×1