public final class OAuthHelper extends Object implements OAuthConstant
PUBLIC_API_HOSTNAME, PUBLIC_API_OAUTH_AUTHORIZE_PATH, PUBLIC_API_OAUTH_AUTHORIZE_URL, PUBLIC_API_OAUTH_DEFAULT_CALLBACK, PUBLIC_API_OAUTH_TOKEN_PATH, PUBLIC_API_OAUTH_TOKEN_URL
Constructor and Description |
---|
OAuthHelper() |
OAuthHelper(String baseOAuthUrl)
Override mechanism to set another base url.
|
Modifier and Type | Method and Description |
---|---|
OAuthData |
getAccessToken(String apiKey,
String apiSecret,
String callback,
String code)
Retrieve the access token.
Once the application has an authorization code, it can exchange this for an access token. |
String |
getAuthorizationUrl(String apiKey,
String callback,
String scope)
Returns default authorization URL for the public API.
Use this method in combination with a Webview to display the Server authentication form. All this information are available on Alfresco Developer Portal |
OAuthData |
refreshToken(OAuthData data)
Request a new accestoken & refreshtoken based on OAuthData information.
|
static String |
retrieveCode(String url)
Retrieve the authorization code from the url callback uri.
|
public OAuthHelper()
public OAuthHelper(String baseOAuthUrl)
baseOAuthUrl
- : new base url like
"https://myoauthtestserver.sample.com"public String getAuthorizationUrl(String apiKey, String callback, String scope)
apiKey
- : API key associated to your application.callback
- : Callback URI associated to your application.scope
- : Scope associated to your application. You should always
use the value public_api for scope.public static String retrieveCode(String url)
url
- : Callback uri that contains authorization code.public OAuthData getAccessToken(String apiKey, String apiSecret, String callback, String code)
apiKey
- : API key associated to your application.apiSecret
- : API secret key associated to your application.callback
- : Callback URI associated to your application.code
- : Authorization codeAlfrescoSessionException
- SESSION_API_KEYS_INVALID
: API key or secret were not
recognized.AlfrescoSessionException
- SESSION_AUTH_CODE_INVALID
: Authorization code is invalid
or expired.public OAuthData refreshToken(OAuthData data)
data
- : OAuthData object available from your cloud session object :
CloudSession.getOAuthData()
AlfrescoSessionException
- SESSION_API_KEYS_INVALID
: API key or secret were not
recognized.AlfrescoSessionException
- SESSION_AUTH_CODE_INVALID
: Refresh token is invalid or
expired.Copyright © 2012-2018 Alfresco Software. All Rights Reserved.