我正在使用Xamarin.Android开发一个应用程序。
我需要启用Facebook和Google登录,我选择使用Xamarin.Auth组件。我和facebook合作过,但我对谷歌有一些意见。
这是我的密码:
var auth = new OAuth2Authenticator (
clientId: "myId.apps.googleusercontent.com",
clientSecret: "mysecred",
scope: "openid",
authorizeUrl: new Uri ("https://accounts.google.com/o/oauth2/auth"),
redirectUrl: new Uri ("myredirect:oob"),
accessTokenUrl: new Uri ("https://accounts.google.com/o/oauth2/token"),
getUsernameAsync: null
);
activity.StartActivity (auth.GetUI (activity));
auth.Completed += (sender, e) => {
Console.WriteLine (e.IsAuthenticated);
};是这样的谷歌活动显示,我可以插入我的用户名和密码。但是,当我点击google登录按钮时,我会收到这样的消息:
请将此代码切换到您的应用程序并粘贴到代码中。
我和那个密码有什么关系?我只需要得到用户名/姓氏/电子邮件/id。
非常感谢!
发布于 2014-09-10 13:17:17
贝娄台阶对我有用。
1.将google控制台注册为webapplication,而不是已安装的应用程序(Android)*在应用程序代码中提供具有有效url ("http://abcd.com/xyz.aspx")的重定向url。
2.认证完成后,它将返回access_token
3.使用access_token发出REST请求获取用户的完整信息(token=“+ accessTokenValue +”)。
4.反序列化json响应以获取对象中的信息。
检查源代码:http://appliedcodelog.blogspot.in/2015/08/login-by-google-account-integration-for.html
https://stackoverflow.com/questions/24849060
复制相似问题