CrossGeeks / GoogleClientPlugin

Google Client Plugin for Xamarin iOS and Android
https://www.pujolsluis.com/google-client-plugin-for-xamarin/
MIT License
89 stars 37 forks source link

Token is empty on Android #17

Closed gaffkins closed 5 years ago

gaffkins commented 6 years ago

After success sign in on aAndroid, token is empty. Log from plugin: Active Token: On ios it is ok

gaffkins commented 6 years ago

I found solution. You must add RequestIdToken GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken(CLIENT_WEB_ID) .RequestEmail().Build();

natsoragge commented 5 years ago

I'm using the latest version of the plugin, which already contains the RequestIdToken, but the ActiveToken stills always null. The sign in is working as expected, I'm able to get name, email, etc.

Pujolsluis commented 5 years ago

Hello Guys, Sorry for the Delay on the answers last months have been a bit intense for me 😋 .

To solve this issue its pretty straightforward on the latest releases we have updated the MainActivity Initialization for the plugin, to allow devs to enable the token on Android, you can do it with the following line of code.

    /* 1st Parameter (MainActivity), 2nd Parameter enables the ServerAuthCode 
    3rd Parameter enables the RequestIdToken. 
    (You pass the server web client id to both parameters).
    */
    GoogleClientManager.Initialize(this, "<web client id>", "<web client id>");

I have updated the Getting Started Guide with a section about this topic, you can read a bit more about it there.

You can also see the code base for the Android Client Manager of the project on lines 40 - 73 to see how we are using the info provided on the initialize method to setup the ApiClient as per Google SDK Documentation.

We are glad you are looking forward to using our plugin in your projects, I hope it comes out great!. As a community we appreciate your support and any collaboration you wish to add to the project! 😄 🙌

natsoragge commented 5 years ago

It's working now! Thank you so much!!

I am glad your Google and Facebook plugins exist, they're helping a lot. 😄 I'd like to suggest you to add Given Name and Family Name fields to the GoogleUser class. That'd help if someone needs them separately.

Pujolsluis commented 5 years ago

I'm glad to hear you got it up and running @natsoragge ! That would be a good addition to the project would you like to do the collab? we review and accept pull requests! :P (I can do it, but its always way more fun to have the community involved haha)

natsoragge commented 5 years ago

Sure! I've just created the pull request.