gpt4 book ai didi

iphone - Google Data/OAuth/AppEngine/Python - 正确注册 Web 应用程序

转载 作者:太空宇宙 更新时间:2023-11-04 01:40:28 25 4
gpt4 key购买 nike

我正在使用这些工具组合创建一个网络应用程序。我通过以下方式使用 App Engine 进行身份验证:

class googleLogin(webapp.RequestHandler):
def get(self):
callbackURL = 'http://%s/googleLoginCallback' % getHost()

#Create a client service
gdClient = gdata.docs.service.DocsService()
gdata.alt.appengine.run_on_appengine(gdClient)
gdClient.SetOAuthInputParameters(gdata.auth.OAuthSignatureMethod.HMAC_SHA1,
_GoogleConsumerKey,
consumer_secret=_GoogleConsumerSecret)

#Get a Request Token
requestToken = gdClient.FetchOAuthRequestToken(scopes=_GoogleDataScope,
extra_parameters={'xoauth_displayname': APP_NAME})

#Persist token secret
self.session = Session()
self.session[TOKENSECRETKEY] = requestToken.secret

gdClient.auto_set_current_token = True
gdClient.SetOAuthToken(requestToken)
authUrl = gdClient.GenerateOAuthAuthorizationURL(callback_url=callbackURL)
self.redirect(authUrl)

我在 https://www.google.com/accounts/ManageDomain 向 Google 验证了我的域,输入目标 URL 并使用给定的消费者 key / secret 。例如,如果我的域名是“juno.appspot.com”,我使用的是 http://juno.appspot.com作为目标 url 路径前缀。

进程正在运行;但是,Google 会在黄色安全框中向用户显示此消息:

"The application that directed you here claims to be 'xxxxxx'. We are unable to verify this claim as the application runs on your computer, as opposed to a website. We recommend that you deny access unless you trust the application."

我认为我不应该收到此错误,因为我的服务器正在获取请求 token 并创建授权 URL。有没有人知道如何摆脱这个警告?

Google 的域注册有一个上传证书的选项,但我不需要这样做,因为我使用的是带有 HMAC_SHA1 签名方法的 OAuth。

此外,这并不重要,但我是通过 iPhone 上的 UIWebView 完成所有这些操作的。我特别尝试在服务器端进行所有身份验证,以避免暴露我的消费者 key / secret 。

感谢您的任何提示:)

最佳答案

已解决。

罪魁祸首是上面的这条线:

extra_parameters={'xoauth_displayname': APP_NAME})

如 Google 文档所示,为已注册的应用程序设置此值会故意触发对用户的警告:

xoauth_displayname:

(optional) String identifying theapplication. This string is displayedto end users on Google's authorizationconfirmation page. For registeredapplications, the value of thisparameter overrides the name setduring registration and also triggersa message to the user that theidentity can't be verified. Forunregistered applications, thisparameter enables them to specify anapplication name, In the case ofunregistered applications, if thisparameter is not set, Googleidentifies the application using theURL value of oauth_callback; ifneither parameter is set, Google usesthe string "anonymous".

删除此行不再允许我使用“好听”的名称代替域,但它摆脱了那个烦人的黄色框:)

关于iphone - Google Data/OAuth/AppEngine/Python - 正确注册 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5527116/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com