public class OAuthAuthenticator extends java.lang.Object implements Authenticator
Constructor and Description |
---|
OAuthAuthenticator(java.lang.String clientId,
java.lang.String clientSecret,
java.lang.String scope,
java.lang.String redirectUri)
Creates a new OAuth authentication strategy
|
Modifier and Type | Method and Description |
---|---|
void |
authorize(java.lang.String code,
CompletionHandler<java.lang.Void> handler)
Authorize with the OAuth authorization code
|
void |
deauthorize()
Deauthorizes the current user and clears any persistent state with regards to the current user.
|
protected java.lang.String |
getClientId() |
protected java.lang.String |
getClientSecret() |
protected java.lang.String |
getRedirectUri() |
protected java.lang.String |
getScope() |
void |
getToken(CompletionHandler<java.lang.String> handler)
Returns an access token of this authenticator.
|
boolean |
isAuthorized()
Returns True if the user is logically authorized.
|
void |
refreshToken(CompletionHandler<java.lang.String> handler)
Refresh an access token of this authenticator.
|
public OAuthAuthenticator(@NonNull java.lang.String clientId, @NonNull java.lang.String clientSecret, @NonNull java.lang.String scope, @NonNull java.lang.String redirectUri)
clientId
- the OAuth client idclientSecret
- the OAuth client secretscope
- space-separated string representing which permissions the application needsredirectUri
- the redirect URI that will be called when completing the authentication. This must match the redirect URI registered to your clientId.public boolean isAuthorized()
Authenticator
This may not mean the user has a valid access token yet, but the authentication strategy should be able to obtain one without further user interaction.
isAuthorized
in interface Authenticator
Authenticator
public void deauthorize()
Authenticator
Phone
is registered,
it should be deregistered before calling this method.deauthorize
in interface Authenticator
Authenticator
public void authorize(@NonNull java.lang.String code, @NonNull CompletionHandler<java.lang.Void> handler)
code
- OAuth authorization codehandler
- the completion handler will be called when authentication is complete, the error to indicate if the authentication process was successful.public void getToken(@NonNull CompletionHandler<java.lang.String> handler)
Authenticator
This may involve long-running operations such as service calls, but may also return immediately. The application should not make assumptions about how quickly this completes.
getToken
in interface Authenticator
handler
- a callback to be executed when completed, with the access token if successfuly retrieved, otherwise nil.Authenticator
public void refreshToken(CompletionHandler<java.lang.String> handler)
Authenticator
This may involve long-running operations such as service calls, but may also return immediately. The application should not make assumptions about how quickly this completes.
refreshToken
in interface Authenticator
handler
- a callback to be executed when completed, with the access token if successfuly retrieved, otherwise nil.protected java.lang.String getClientId()
protected java.lang.String getClientSecret()
protected java.lang.String getScope()
protected java.lang.String getRedirectUri()