public class TokenProvider extends Object implements ITokenProvider
Class TokenProvider allows to retrieve access token for mail services.
Modifier and Type | Class and Description |
---|---|
static class |
TokenProvider.Google
Provides an instance of the TokenProvider for Google mail server
|
static class |
TokenProvider.Outlook
Provides an instance of the TokenProvider for Outlook mail server
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Performs releasing resources.
|
OAuthToken |
getAccessToken()
Gets oAuth access token.
|
OAuthToken |
getAccessToken(boolean ignoreExistingToken)
Gets oAuth access token.
|
String |
getClientId()
The client ID obtained during application registration.
|
String |
getClientSecret()
The client secret obtained during application registration.
|
com.aspose.ms.System.Collections.Generic.KeyValuePair<String,String>[] |
getExtraParameters()
Gets extra parameters for request
|
static TokenProvider |
getInstance(String requestUrl,
String clientId,
String clientSecret,
String refreshToken)
Gets an instance of the OutlookTokenProvider for defined parameters.
|
String |
getLogin()
Gets or sets login for basic authorization
|
String |
getPassword()
Gets or sets password for basic authorization
|
String |
getRefreshToken()
OAuth 2.0 refresh token
|
String |
getRequestUrl()
The url to obtain access token.
|
boolean |
getUseBasicAuthorization()
Gets or sets value which indicates whether basic authorization is used
|
void |
setLogin(String value)
Gets or sets login for basic authorization
|
void |
setPassword(String value)
Gets or sets password for basic authorization
|
void |
setUseBasicAuthorization(boolean value)
Gets or sets value which indicates whether basic authorization is used
|
public static TokenProvider getInstance(String requestUrl, String clientId, String clientSecret, String refreshToken)
Gets an instance of the OutlookTokenProvider for defined parameters.
requestUrl
- The url to obtain access token.clientId
- The client ID obtained from the Microsoft account Developer Center during application registration.clientSecret
- The client secret obtained during application registration.refreshToken
- OAuth 2.0 refresh tokenpublic void dispose()
Performs releasing resources.
dispose
in interface com.aspose.ms.System.IDisposable
public boolean getUseBasicAuthorization()
Gets or sets value which indicates whether basic authorization is used
public void setUseBasicAuthorization(boolean value)
Gets or sets value which indicates whether basic authorization is used
public String getLogin()
Gets or sets login for basic authorization
public void setLogin(String value)
Gets or sets login for basic authorization
public String getPassword()
Gets or sets password for basic authorization
public void setPassword(String value)
Gets or sets password for basic authorization
public String getRequestUrl()
The url to obtain access token.
public com.aspose.ms.System.Collections.Generic.KeyValuePair<String,String>[] getExtraParameters()
Gets extra parameters for request
public String getClientId()
The client ID obtained during application registration.
public String getClientSecret()
The client secret obtained during application registration.
public String getRefreshToken()
OAuth 2.0 refresh token
public OAuthToken getAccessToken()
Gets oAuth access token. If token exists and its expiration date is not expired returns current token, otherwise requests new token from a server.
getAccessToken
in interface ITokenProvider
public OAuthToken getAccessToken(boolean ignoreExistingToken)
Gets oAuth access token.
getAccessToken
in interface ITokenProvider
ignoreExistingToken
- If ignoreExistingToken is true, requests new token from a server. Otherwise behaviour is depended on whether token exists or not.
If token exists and its expiration date is not expired returns current token, otherwise requests new token from a server.