XMPP Google Talk X-OAUTH2登录名需要用户名 [英] XMPP Google Talk X-OAUTH2 login requires username
问题描述
我正在为使用相对较新的X-OAUTH2机制的Google Talk实施XMPP客户端.我的想法是,我不需要存储用于对服务进行身份验证的用户名或密码.但是,用于X-OAUTH2身份验证的 Google文档指出,这是初始的<auth>
请求制作:
I'm implementing an XMPP client for Google Talk that is using the relatively new X-OAUTH2 mechanism. I had the idea that I shouldn't need to store either username or password for the authentication to the service. However, Google's documentation for the X-OAUTH2 authentication states this is the initial <auth>
request to make:
<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl"
mechanism="X-OAUTH2"
auth:service="oauth2"
xmlns:auth="http://www.google.com/talk/protocol/auth">
base64("\0" + user_name + "\0" + oauth_token)
</auth>
请注意,它要求将"user_name"与令牌一起发送.这里有我想念的东西吗?还是我真的必须在应用程序提示符下输入用户名? (请注意,用户已经通过OAuth2登录以接收访问令牌)
Note that it requires the "user_name" to be sent along with the token. Is there something I'm missing here? Or do I really have to have my application prompt for the username? (Note that the user would already have logged in via OAuth2 to receive the access token)
我不知道有任何其他使用OAuth的服务需要客户端提供用户名.例如,同一应用可以通过XMPP和OAuth2连接到Facebook聊天,而无需在XMPP中提供用户名.
I don't know of any other service that uses OAuth that requires the client to provide a username. For instance, this same app can connect to Facebook Chat via XMPP and OAuth2 without needing the username to be provided in XMPP.
推荐答案
您无需在应用程序中提示输入用户名.只需将"SCOPE"参数指定为"https://www.googleapis.com/auth/userinfo.email"即可. 请参考此.这将为您提供用户的电子邮件ID和令牌.
You don't need to prompt for username in your application. Just specify "SCOPE" parameter as "https://www.googleapis.com/auth/userinfo.email". Refer this. This will give you users email-ID in response along with token.
此链接包含有关Google帐户身份验证和授权的详细说明.您可以在应用程序中使用的getUserInfo()函数中返回用户名和电子邮件ID.
This Link has detailed explanation about Google Accounts Authentication and Authorization. Username and email-id is returned in getUserInfo() function which you can use in your application.
这篇关于XMPP Google Talk X-OAUTH2登录名需要用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!