How to show a floating window to enter Google Plus in Android

I need to implement signin with facebook and google plus in an android app. Successfully implemented facebook as shown in the image below. enter image description here

But when I implement the login with google plus, it shows that google link plus images

Please help me implement the same as Facebook Login to sign in to Google plus on Android. So that the user can enter any gmail account that he prefers to log in to Google.

+5
source share
1 answer

I use the SocialAuth library, which supports many social networks, including Facebook and Google+ .

Note. If necessary, you can give examples of the code to enter the relevant social networks using this library (Facebook, Google+) later.

Update:

1) the client identifier is stored in the oauth_consumer.properties file (put it in the assets folder)

 #facebook graph.facebook.com.consumer_key = YOUR_KEY graph.facebook.com.consumer_secret = YOUR_SECRET #Google Plus googleapis.com.consumer_key=YOUR_KEY.apps.googleusercontent.com googleapis.com.consumer_secret=YOUR_SECRET 

2) Google+ is required to redirect the URL. Specify the redirect URL in the project’s Google console and add it to the SocialAdapter during initialization.

 ... socialAuthAdapter = new SocialAuthAdapter(new ResponseListener(), null); setAuthProviders(); ... private void setAuthProviders() { socialAuthAdapter.addProvider(SocialAuthAdapter.Provider.FACEBOOK, R.drawable.facbook); socialAuthAdapter.addProvider(SocialAuthAdapter.Provider.GOOGLEPLUS, R.drawable.google); socialAuthAdapter.addCallBack(SocialAuthAdapter.Provider.GOOGLEPLUS, GOOGLE_PLUS_CALLBACK_URL); //urn:ietf:wg:oauth:2.0:oob - if you set this url, than accessToken received from social network should be handled manually (web page (in WebView) with login response from Google+ will contain in header or in response link accessToken, and you will get it manually by parsing that links). not the best way. socialAuthAdapter.enable(social); } 

3) You will receive accessToken in ResponseListener when login is completed:

 private class ResponseListener implements DialogListener { @Override public void onComplete(Bundle bundle) { final String providerName = bundle.getString(SocialAuthAdapter.PROVIDER); SocialNetwork network = SocialNetwork.valueOf(providerName); String accessToken = socialAuthAdapter.getCurrentProvider().getAccessGrant().getKey(); } @Override public void onError(final SocialAuthError socialAuthError) { } @Override public void onCancel() { } @Override public void onBack() { } } 

Read more about URL redirection here in the section "Generating a URL for an authentication request."

+1
source

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


All Articles