Skip to content

Latest commit

 

History

History
70 lines (52 loc) · 2.64 KB

README.md

File metadata and controls

70 lines (52 loc) · 2.64 KB

Hybrid Social Login AuthCode Library

This is a Hybrid Social Login AuthCode Library, which is very useful when we want to implement social login feature using the AuthCode grant type.

Current, supported Social Login Providers

  • Google
  • Facebook
  • Linkedin
  • Twitter

Note: If you want us to add support for other social providers, please let us know here, Request New Feature.

The library is available on Maven Central

You can easily use this library in your project because we have deployed it on Maven Central, try now Get Library from Maven Central.

How to Use this Library

As this a hybrid auth-code grant type library, so here you should get the auth-code from the frontend and then use that code to get the user from the social provider via using this library.

In the case of Twitter, you will get oauthToken and oauthVerifier from the frontend. Because Twitter uses the oauth1 protocol.

Note: In case you are looking for the 100% backend integration library, Go Here.

Prerequisites

You will need a clientId, clientSecret, and pre-configured redirectUri.

// authCode which we got from the frontend
String authCode = "dummyAuthCode";

SocialLoginProvider socialProvider;
SocialUser socialUser; 

// get facebook user
socialProvider = new FacebookProvider(facebookclientId, facebookClientSecret, facebookRedirectUri);
socialUser = socialProvider.getUser(new SocialLoginDetail(authCode));

// get Linkedin user
socialProvider = new LinkedinProvider(linkedinClientId, linkedinClientSecret, linkedinRedirectUri);
socialUser = socialProvider.getUser(new SocialLoginDetail(authCode));

// get Google user
socialProvider = new GoogleProvider(googleClientId, googleClientSecret, googleRedirectUri);
socialUser = socialProvider.getUser(new SocialLoginDetail(authCode));


// oauthToken & oauthVerifier which we got from the frontend
String oauthToken = "dummyOauthToken";
String oauthVerifier = "dummyOauthVerifier";

// get Twitter user
socialProvider = new TwitterProvider(twitterClientId, twitterClientSecret);
socialUser = socialProvider.getUser(new SocialLoginDetail(oauthToken, oauthVerifier));

And we are done, that's all we have to do 😊

License

License: MIT

The MIT License