Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Account login Integration for android Xamarin

I need to integrate google login to android xamarin application. gone through the code from bellow link: http://motzcod.es/post/67077106339/google-plus-services-login-and-1-in-xamarin-android

it shows the error connection failed and [GooglePlayServicesUtil] Google Play Store is missing. even ofter adding google play service(Froyo) component.

even i gone through the bellow links https://developers.google.com/+/mobile/android/sign-in

Android: Login using google account?

Google Login For Android App

but this is related to android eclipse using java code. can anybody suggest me how to do this in xamarin. any hints/links are appreciated. thank you.

like image 239
Suchith Avatar asked Aug 27 '14 06:08

Suchith


People also ask

How does Xamarin form integrate with Google login?

Go to the Credentials tab and in the CREATE CREDENTIALS drop-down, select OAuth Client ID. On the next page, select Android in the radio button provided. Other options related to Android will then be shown. On this page, provide any value in the Name field.

Is Xamarin deprecated Android?

In May 2020, Microsoft announced that Xamarin. Forms, a major component of its mobile app development framework, would be deprecated in November 2021 in favour of a new .

Is Xamarin good for Android development?

Since its appearance in 2011, Xamarin has become a great option for cross-platform app development, a faster way to build iOS, Android, and Windows apps.

Is Xamarin free for commercial use?

Open-source and free NET platform that has a strong community of contributors from more than 3,700 companies. . NET is free, and that includes Xamarin. There are no fees or licensing costs, including for commercial use.


2 Answers

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

like image 88
Suchith Avatar answered Sep 30 '22 11:09

Suchith


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.

like image 25
Philip Nelson Avatar answered Sep 30 '22 11:09

Philip Nelson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!