play.libs

## Class OAuth2

- java.lang.Object
- - play.libs.OAuth2

    public class OAuth2
    extends java.lang.Object

Library to access resources protected by OAuth 2.0. For OAuth 1.0a, see play.libs.OAuth. See the facebook-oauth2 example for usage.

### Nested Class Summary

Nested Classes
`static class` `OAuth2.Error`
`static class` `OAuth2.Response`

### Field Summary

Fields
`java.lang.String` `accessTokenURL`
`java.lang.String` `authorizationURL`
`java.lang.String` `clientid`
`java.lang.String` `secret`

### Constructor Summary

Constructors
Constructor and Description
`OAuth2(java.lang.String authorizationURL, java.lang.String accessTokenURL, java.lang.String clientid, java.lang.String secret)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`java.lang.String` `getAccessToken()` Deprecated. Use @{link play.libs.OAuth2.retrieveAccessToken()} instead
`static boolean` `isCodeResponse()`
`void` `requestAccessToken()` Deprecated. Use @{link play.libs.OAuth2.retrieveVerificationCode()} instead
`OAuth2.Response` `retrieveAccessToken()`
`OAuth2.Response` `retrieveAccessToken(java.lang.String callbackURL)`
`void` `retrieveVerificationCode()`
`void` `retrieveVerificationCode(java.lang.String callbackURL)` First step of the OAuth2 process: redirects the user to the authorisation page
`void` `retrieveVerificationCode(java.lang.String callbackURL, java.util.Map<java.lang.String,java.lang.String> parameters)` First step of the oAuth2 process.
`void` `retrieveVerificationCode(java.lang.String callbackURL, java.lang.String parameterName, java.lang.String parameterValue)` First step of the oAuth2 process.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### authorizationURL

    public java.lang.String authorizationURL

#### accessTokenURL

    public java.lang.String accessTokenURL

#### clientid

    public java.lang.String clientid

#### secret

    public java.lang.String secret

### Constructor Detail

#### OAuth2

    public OAuth2(java.lang.String authorizationURL,
                  java.lang.String accessTokenURL,
                  java.lang.String clientid,
                  java.lang.String secret)

### Method Detail

#### isCodeResponse

    public static boolean isCodeResponse()

#### retrieveVerificationCode

    public void retrieveVerificationCode(java.lang.String callbackURL)

First step of the OAuth2 process: redirects the user to the authorisation page

Parameters:
  `callbackURL` - The callback URL

#### retrieveVerificationCode

    public void retrieveVerificationCode(java.lang.String callbackURL,
                                         java.lang.String parameterName,
                                         java.lang.String parameterValue)

First step of the oAuth2 process. This redirects the user to the authorization page on the oAuth2 provider. This is a helper method that only takes one parameter name,value pair and then converts them into a map to be used by `retrieveVerificationCode(String, Map)`

Parameters:
  `callbackURL` - The URL to redirect the user to after authorization
  `parameterName` - An additional parameter name
  `parameterValue` - An additional parameter value

#### retrieveVerificationCode

    public void retrieveVerificationCode(java.lang.String callbackURL,
                                         java.util.Map<java.lang.String,java.lang.String> parameters)

First step of the oAuth2 process. This redirects the user to the authorisation page on the oAuth2 provider.

Parameters:
  `callbackURL` - The URL to redirect the user to after authorisation
  `parameters` - Any additional parameters that weren't included in the constructor. For example you might need to add a response_type.

#### retrieveVerificationCode

    public void retrieveVerificationCode()

#### retrieveAccessToken

    public OAuth2.Response retrieveAccessToken(java.lang.String callbackURL)

#### retrieveAccessToken

    public OAuth2.Response retrieveAccessToken()

#### requestAccessToken

    @Deprecated
    public void requestAccessToken()

Deprecated. Use @{link play.libs.OAuth2.retrieveVerificationCode()} instead

#### getAccessToken

    @Deprecated
    public java.lang.String getAccessToken()

Deprecated. Use @{link play.libs.OAuth2.retrieveAccessToken()} instead

Returns:
  The access token