scribe-up ("up" for User Profile) is a web OAuth client to :
- delegate authentication and permissions to an OAuth provider (i.e. the user is redirected to the OAuth provider to log in)
- (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).
Web site | Protocol | Provider | Profile |
sites using OAuth Wrapper for CAS server | OAuth 2.0 | CasOAuthWrapperProvider | CasOAuthWrapperProfile |
DropBox | OAuth 1.0 | DropBoxProvider | DropBoxProfile |
OAuth 2.0 | FacebookProvider | FacebookProfile | |
Github | OAuth 2.0 | GitHubProvider | GitHubProfile |
OAuth 1.0 & 2.0 | GoogleProvider & Google2Provider | GoogleProfile & Google2Profile | |
OAuth 1.0 | LinkedInProvider | LinkedInProfile | |
OAuth 1.0 | TwitterProvider | TwitterProfile | |
Windows Live | OAuth 2.0 | WindowsLiveProvider | WindowsLiveProfile |
WordPress | OAuth 2.0 | WordPressProvider | WordPressProfile |
Yahoo | OAuth 1.0 | YahooProvider | YahooProfile |
Follow the guide to extend or add a new provider.
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.
Even if you can use scribe-up on its own, this library is used to be the foundation of :
- the cas-server-support-oauth module to add OAuth client and server support to the CAS server
- the buji-oauth library to add OAuth client support to the Apache Shiro project
- the spring-security-oauth-client library to add OAuth client support to Spring Security.
- the play-oauth-client library to add OAuth client support to the Play 2.0 framework.
Library | Based on scribe-up version | Demo webapp |
---|---|---|
cas-server-support-oauth 3.5.2 | 1.2.0 | cas-oauth-demo-3.5.x |
cas-server-support-oauth 3.5.1 | 1.1.0 | cas-oauth-demo-3.5.x |
cas-server-support-oauth 3.5.0 | 1.0.0 | cas-oauth-demo-3.5.0 |
buji-oauth 1.1.0 | 1.3.1 | buji-oauth-demo |
buji-oauth 1.0.0 | 1.2.0 | buji-oauth-demo-1.0.0 |
spring-security-oauth-client 1.1.0 | 1.3.1 | spring-security-oauth-client-demo |
spring-security-oauth-client 1.0.0 | 1.2.0 | spring-security-oauth-client-demo-1.0.0 |
play-oauth-client 1.0.0 | 1.3.1 | play-oauth-client-java-demo play-oauth-client-scala-demo |
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>
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).
Find me on LinkedIn or by email : leleuj@gmail.com