Google Account login Integration for android Xamarin

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.


Comments

  1. Graham

    • 2015/11/12

    To integrate Google login in your Xamarin.Forms application, you need to create a project for your application in the Google developer console.

  2. Davis

    • 2015/8/20

    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.

  3. Brown

    • 2020/5/27

    Create a new Xamarin.Android project in Visual Studio. Configure the new project by selecting the Blank template. Integrate the Google Identity 

  4. Maxwell

    • 2017/5/25

    User46378 posted I need to integrate google login to android application. gone through the code from bellow link: http://motzcod.es/post/67077106339/google-plus

  5. Sterling

    • 2019/12/9

    2 Answers · Register in google developer console as webapplication instead of installed application(android)* provide the redirect url with valid 

  6. Orion

    • 2021/3/8

    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.

  7. Berisha

    • 2017/12/18

    Demonstrates how to authenticate a user with the Google Api Client in Google Play Services.

  8. Grayson

    • 2016/10/12

    Introduction. Gmail Login is an easy way for users to log in. Gmail Login automatically retrieves all the user information. Let’s start! Before starting our Android application creation, we need to create a Gmail Developer account's new application and enable Google API.

  9. Thomas

    • 2020/3/1

    Go to API Console from https://console.developers.google.com/apis/dashboard. Check the page on the left side corner and go to Project Name 

  10. Vincent

    • 2017/3/11

    Google authentication. To do this integration we will be using the Plugin.GoogleClient. The result will look like this: Let’s start: 1-Firebase portal setup. Few months ago we wrote a detailed guide of how to set up you can follow it step by step here. 2-Install the Plugin.GoogleClient. 3-Add the Android/iOS platform configurations

  11. Roland

    • 2017/5/30

    In this one, we will be integrating Google login in a Xamarin Forms application. In your Android project, add these configurations.

  12. Hasani

    • 2016/6/3

    Android and Xamarin.iOS. Brief: Google Account integration to the app, helps for the user authentication using their existing Google account 

  13. Ryan

    • 2015/9/15

    www.pujolsluis.com/google-client-plugin-for-xamarin/ Cross platform plugin for handling Google authentication. Xamarin.Android, API 15+ 

Comments are closed.

Recent Posts