Skip to content

pwheel/scribe-up

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is scribe-up ?

scribe-up ("up" for User Profile) is a web OAuth client to :

  1. delegate authentication and permissions to an OAuth provider (i.e. the user is redirected to the OAuth provider to log in)
  2. (in the application) retrieve the profile of the authorized user after successfull authentication and permissions acceptation (at the OAuth provider).

It's available under the Apache 2 license and based on : scribe-java (for OAuth protocol) and Jackson (for JSON parsing).

OAuth providers supported

Web siteProtocolProviderProfile
sites using OAuth Wrapper for CAS serverOAuth 2.0CasOAuthWrapperProviderCasOAuthWrapperProfile
DropBoxOAuth 1.0DropBoxProviderDropBoxProfile
FacebookOAuth 2.0FacebookProviderFacebookProfile
GithubOAuth 2.0GitHubProviderGitHubProfile
GoogleOAuth 1.0 & 2.0GoogleProvider & Google2ProviderGoogleProfile & Google2Profile
LinkedInOAuth 1.0LinkedInProviderLinkedInProfile
TwitterOAuth 1.0TwitterProviderTwitterProfile
Windows LiveOAuth 2.0WindowsLiveProviderWindowsLiveProfile
WordPressOAuth 2.0WordPressProviderWordPressProfile
YahooOAuth 1.0YahooProviderYahooProfile

Follow the guide to extend or add a new provider.

Code sample

Suppose you want to authenticate and get the user profile from Facebook :

// declare the provider (use default scope and fields)
FacebookProvider provider = new FacebookProvider();
provider.setKey(MY_KEY);
provider.setSecret(MY_SECRET);
provider.setCallbackUrl("http://myserver/myapp/callbackUrl");
// send the user to Facebook for authentication and permissions
response.sendRedirect(provider.getAuthorizationUrl(new HttpUserSession(session)));

...after successfull authentication, on the callback url for Facebook...

// get OAuth credentials
OAuthCredential credential = provider.getCredential(new HttpUserSession(request), request.getParameterMap());
// get the user profile
UserProfile userProfile = provider.getUserProfile(credential);
// get the facebook profile
FacebookProfile facebookProfile = (FacebookProfile) userProfile;
System.out.println("Hello : " + facebookProfile.getDisplayName() + " born the " + facebookProfile.getBirthday());

If the user can be authenticated by several OAuth providers, use the common profile instead :

CommonProfile commonProfile = (CommonProfile) userProfile;
System.out.println("Hello : " + commonProfile.getDisplayName() + " at " + commonProfile.getEmail());

If you want to interact more with the OAuth provider, you can retrieve the access token from the (OAuth) profile :

OAuthProfile oauthProfile = (OAuthProfile) userProfile;
String accessToken = oauthProfile.getAccessToken();
// or
String accesstoken = facebookProfile.getAccessToken();

For a better understanding of scribe-up, take a look at the technical description of the project or browse the Javadoc.

Libraries built on scribe-up

Even if you can use scribe-up on its own, this library is used to be the foundation of :

  1. the cas-server-support-oauth module to add OAuth client and server support to the CAS server
  2. the buji-oauth library to add OAuth client support to the Apache Shiro project
  3. the spring-security-oauth-client library to add OAuth client support to Spring Security.
  4. the play-oauth-client library to add OAuth client support to the Play 2.0 framework.
LibraryBased on scribe-up versionDemo webapp
cas-server-support-oauth 3.5.21.2.0cas-oauth-demo-3.5.x
cas-server-support-oauth 3.5.11.1.0cas-oauth-demo-3.5.x
cas-server-support-oauth 3.5.01.0.0cas-oauth-demo-3.5.0
buji-oauth 1.1.01.3.1buji-oauth-demo
buji-oauth 1.0.01.2.0buji-oauth-demo-1.0.0
spring-security-oauth-client 1.1.01.3.1spring-security-oauth-client-demo
spring-security-oauth-client 1.0.01.2.0spring-security-oauth-client-demo-1.0.0
play-oauth-client 1.0.01.3.1play-oauth-client-java-demo
play-oauth-client-scala-demo

Versions

The last released version is the 1.3.1. Learn more about the different versions.

The current version : 1.3.2-SNAPSHOT is under development, it's available on Sonatype snapshots repository as Maven dependency :

<dependency>
    <groupId>org.scribe</groupId>
    <artifactId>scribe-up</artifactId>
    <version>1.3.2-SNAPSHOT</version>
</dependency>

Testing

scribe-up is tested by more than 200 unit, bench and integration tests on OAuth providers (which simulate complete authentication processes using the HtmlUnit library).

Contact

Find me on LinkedIn or by email : leleuj@gmail.com

About

Web OAuth client with user profile retrieval

Resources

License

Stars

Watchers

Forks

Packages

No packages published