Package play.libs

Class 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.
    • 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)
      • 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