Google Account login Integration for android Xamarin

落花浮王杯 提交于 2019-11-30 04:14:17

Finally i got a solution by doing the research over the available codes from xamarin forum and stackoverflow. I made use of the OAuth2Authenticator

  1. Register in google developer console as webapplication instead of installed application(android)* provide the redirect url with valid url ("http://abcd.com/xyz.aspx") same should be used in the application code.

  2. On authentication complete it will return access_token

  3. By using the access_token make the REST request to get user complete information (https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + accessTokenValue + “.)

  4. Deserialize the json response to get information in object.

*If we registered in developer console as installed application(like android) after making OAuth2Authenticator request it will show window with message please copy this code switch to your application and paste it there [code] manually need to close the window and proceed to authentication. to get ride of this webapplication type is choosen.

Refer for more info. : Login by google account integration for Xamarin.Android and Xamarin.iOS

The answer given is great. It works without trouble so long as that redirecturi is a real and accessible url for the underlying WebView to connect to at the end of the flow. In a mobile scenario this really doesn't make sense but google requires it. The examples typically say use localhost as the redirecturi which leads to a 401 UnAuthorized response showing in the UI. Ugh. Authentication is successful, but you have this ugly box you have to click on.

My solution on this was to have the redirecturi be the me link, https://www.googleapis.com/plus/v1/people/me. The code you have completes, there are no errors and the view is dismissed. Hope this helps somebody.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!