Using your Google account as a login ... what's next?

I am developing an Android application that will have an avaliable server side. And this application will have login mechanisms. I want to use google / fb / twitter account as login information as the purpose of the application is very social.

I already read about using a Google account stored on the phone as a user check ( How to use Google accounts as login ). The problem is that I do not know what to do then? As I understand it, the Account Manager will finally give me a token. Then what should I do with this? How to tell the server that the user is logged in? How can I store this token, since I realized that this token can change after cancellation after some time ...

One more thing. What should I do when a user logs into their G account for the first time? For example, I want to get his G-image and display name and save them on the server, while saving the user a few clicks? Do I send them somehow from the phone, or do I somehow get them from the server?

The same questions may arise for FB later.

Hope I asked my question correctly, as this is a slightly more general question ...

TIA.

+6
source share
3 answers

I think this question covers exactly what you ask.

For me, the best solution was reviewed on this blog. It will only work with Google accounts and assumes that you are using UserService on the AppEngine side, but I think it works well. Hope this helps.

+2
source

Google uses OpenId, and FB has its own thing. For these two, you will need different encodings.

http://www.sozkan.com/blog/2010/09/24/very-quick-openid-integration-tutorial/

Provided - it depends on the URLs for data management - you will need to wrap this in your code if you want all this to happen internally. After you have a token, you can notify your server code about what it is, its lifespan, etc.

Difference Information: http://thenextweb.com/socialmedia/2010/11/04/facebook-connect-oauth-and-openid-the-differences-and-the-future/

+1
source

Just to finish this (obsolete) question and to park my code fragment somewhere, I started registering with Google using PreferenceScreen Activity with this onCreate() code:

  ArrayList<String> list = new ArrayList<String>(); list.add("https://www.googleapis.com/auth/userinfo.profile"); final GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(getApplicationContext(), list); Preference acctValue = findPreference("GMail"); // A <Preference> in the XML... acctValue.setOnPreferenceClickListener(new OnPreferenceClickListener(){ @Override public boolean onPreferenceClick(Preference preference) { startActivityForResult(credential.newChooseAccountIntent(), 1); return false; } }); 

And they demanded to add these shadowy characters to my libs folder:

 google-api-client-android-1.17.0-rc.jar google-play-services.jar google-api-client-1.17.0-rc.jar google-http-client-1.17.0-rc.jar 
0
source

Source: https://habr.com/ru/post/892750/


All Articles