我使用Facebook登录来识别用户.当新用户到来时,我将他们的userID存储在我的数据库中.下次他们来的时候,我认出了他们的Facebook ID,我知道它在我的数据库中是哪个用户.
现在我想尝试使用Google的OAuth2,但我怎样才能识别用户?
Google向我发送了几个代码和令牌(access_token,id_token,refresh_token),但它们都不是常量.这意味着如果我在2分钟后退出并重新登录,则所有3个值都已更改.如何唯一标识用户?
我正在使用他们的PHP客户端库:https://code.google.com/p/google-api-php-client/
我们有一个独立的Java应用程序(请参阅"安装应用程序":https://developers.google.com/accounts/docs/OAuth2)的定期运行,并使用谷歌API(从客户数据库/ LDAP更新一些信息/ ...) .
要访问Google API,我们会在配置文件中存储用户名和密码,这是一种安全风险,客户不喜欢这样做.因此,我们希望使用OAuth2长期访问令牌.
Google OAuth2访问令牌的默认到期时间是什么时候?
由于我们在应用程序中只有访问令牌,因此当访问令牌到期时,应用程序本身无法刷新它...
我个人认为在这种情况下OAuth2的实现不会带来任何重大好处,但让我们关注主要问题 - 默认的到期时间.
security google-api oauth-2.0 google-api-java-client google-oauth
我正在尝试使用Postman Chrome应用程序访问Proximity Google API.我已经关注邮递员和谷歌开发网站的教程,但我仍然收到401错误消息.
我在做什么?
In order to use Proximity API, it has to be first enabled in Google Dev console. Using this tutorial I have enabled support for Proximity API for my project
According to this tutorial, I need to get client ID and secret. This is where I am confused. Credentials->Add credentials->OAuth2.0 client ID->select Chrome App radio button (since I am using Postman)->enter last …
google-api oauth-2.0 google-api-client postman google-oauth2
我尝试发布sereval范围值,以允许我的应用程序的一些谷歌服务...
我尝试了两个输入字段
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/calendar" />
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/userinfo.email" />
Run Code Online (Sandbox Code Playgroud)
并带有一个带+分隔符的输入字段
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/calendar+https://www.googleapis.com/auth/userinfo.email" />
Run Code Online (Sandbox Code Playgroud)
当我发送只有一个范围的表单时它工作.否则与sereval范围值谷歌重定向我与此错误描述:
http://localhost:49972/redirect.aspx#error=invalid_request&error_description=OAuth+2+parameters+can+only+have+a+single+value:+scope&error_uri=http://code.google.com/apis/accounts/docs/OAuth2.html
Run Code Online (Sandbox Code Playgroud)
在google 开始使用oAuth2时,它可以使用两个范围值.
这是我的代码:
<form id="form1" method="post" action="https://accounts.google.com/o/oauth2/auth?" >
<div>
<input type="hidden" name="response_type" value="code" />
<input type="hidden" name="client_id" value="my client id" />
<input type="hidden" name="redirect_uri" value="http://localhost:49972/redirect.aspx" />
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/calendar" />
<input type="hidden" name="scope" value="https://www.googleapis.com/auth/userinfo.email" />
<input type="hidden" name="state" value="/profile" />
<input type="submit" value="go" />
</div>
</form>
Run Code Online (Sandbox Code Playgroud) 我们有一些应用程序(或者也许我们应该称它们为一些脚本)使用 Google API 来促进一些管理任务。最近,在同一项目中创建另一个 client_id 后,我开始收到一条错误消息,类似于localhost redirect_uri does not work for Google Oauth2 (results in 400: invalid_request error)中描述的错误消息。IE,
\n\n\n错误 400:无效的请求
\n您无法登录此应用,因为它不符合 Google\nOAuth 2.0 确保应用安全的政策。
\n您可以让应用开发者知道此应用不符合\n一个或多个 Google 验证规则。
\n请求详情:
\n此部分中的内容由应用开发者提供。\n此内容未经 Google 审核或验证。
\n如果您\xe2\x80\x99是应用开发者,请确保这些请求详细信息\n符合 Google 政策。
\n重定向_uri:瓮:ietf:wg:oauth:2.0:oob
\n
我该如何解决这个错误?需要注意的是:
\nurn:ietf:wg:oauth:2.0:oob重定向 URI(复制/粘贴是在没有浏览器的无头计算机上运行此脚本的唯一友好方法)。使用服务帐户访问Google Play Developer API时出现以下错误:
用于调用Google Play Developer API的项目ID尚未在Google Play开发者控制台中进行链接.
服务帐户电子邮件和.p12文件是使用服务帐户选项生成的APIs&Auth -> Credentials.Google Play Developer API中的应用程序使用google文档中提到的项目ID链接到项目.
但是,当我尝试使用Publishing API时,我仍然收到此错误.我正在寻找这个错误的解决方案以及使用Google Publishing API为Java客户端使用Google Play Developer API发布APK的一步一步的流程.我在用androidpublisher_v2_public.
我想获得使用Google中的特殊功能的搜索结果,例如"define:[phrase]",我似乎无法找到相关的相关信息.
有没有人知道我可以在哪里获得JSON格式的数据(比如Google的其他API),而无需手动抓取结果页面?
谢谢,Eli
我一整天都在寻找一个好的解决方案,但谷歌进化得如此之快,以至于找不到合适的东西.我想要做的是,我有一个Web应用程序,其中有一个管理部分,用户需要登录才能查看信息.在本节中,我想显示来自GA的一些数据,例如某些特定网址的综合浏览量.因为它不是用户信息我展示,但谷歌analytics'user我想连接传递信息(用户名/密码或APIKey),但我不能找出如何.我发现的所有样本都使用了OAuth2(如果我理解的话,会要求访问者使用谷歌登录).
到目前为止我发现了什么:
也许我只是累了,明天很容易找到解决方案,但现在我需要帮助!
谢谢
我正在尝试GoogleAuth使用该pydrive库(https://pypi.python.org/pypi/PyDrive)自动化该过程.
我已经设置了pydrive和google API,以便我的secret_client.json工作,但每次运行我的脚本时都需要对gdrive访问进行Web身份验证:
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
textfile = drive.CreateFile()
textfile.SetContentFile('eng.txt')
textfile.Upload()
print textfile
drive.CreateFile({'id':textfile['id']}).GetContentFile('eng-dl.txt')
Run Code Online (Sandbox Code Playgroud)
eng.txt只是一个文本文件.此外,当我登录到另一个帐户时,我尝试使用上面的脚本.它不会上传eng.txt到生成我的gdrive secret_client.json但是我授权身份验证时登录的帐户
从上一篇文章中,我尝试了以下内容来自动执行验证过程,但它给出了错误消息:
import base64, httplib2
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
#gauth = GoogleAuth()
#gauth.LocalWebserverAuth()
# from google API console - convert …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的网络应用上实施Google plus注册,然后我按照谷歌文档设置注册但是当我在接受权限后尝试注册并使用访问令牌返回给我任何api restcall我返回超出未经身份验证的使用的每日限制.继续使用需要注册错误.我已经使用ouath 2.0密钥注册了我的应用程序,所以我似乎没有得到我做错了什么.这是我的代码.
方方:
const clientId = "5XXX000XX.apps.googleusercontent.com";
const apiKey = "AIzaSyCAXE5JSa36jcC*X7HV40SBcIWBiVGUTBE";
const scopes = "https://www.googleapis.com/auth/plus.login";
let accessToken = null;
function initer() {
gapi.client.setApiKey(apiKey);
// alert("Hello init");
if ($("#authorize-button").length > 0) {
$("#authorize-button").click(onLoginClick);
}
}
function onLoginClick() {
// $("#modalLoading").modal();
// alert("yeah");
gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: false }, onConnect);
}
function onConnect(authResult) {
// alert("On connect");
if (authResult && !authResult.error) {
alert("Hey");
accessToken = authResult.access_token;
triggerLogin();
} else {
alert("Error");
}
}
triggerLogin = function() {
alert("Triggering …Run Code Online (Sandbox Code Playgroud) google-api ×10
oauth-2.0 ×5
google-oauth ×2
.net ×1
c# ×1
cloud ×1
google-plus ×1
javascript ×1
json ×1
login ×1
oauth ×1
php ×1
postman ×1
pydrive ×1
python ×1
security ×1