C# Class Smartsheet.Api.Internal.OAuth.OAuthFlowImpl

Default implementation of OAuthFlow. Thread Safety: Implementation of this interface must be thread safe.
Inheritance: Api.OAuth.OAuthFlow
Show file Open project: smartsheet-platform/smartsheet-csharp-sdk Class Usage Examples

Public Methods

Method Description
ExtractAuthorizationResult ( string authorizationResponseURL ) : Api.OAuth.AuthorizationResult

Extract AuthorizationResult from the authorization response URL (i.e. the RedirectURL with the response parameters from Smartsheet OAuth server). Exceptions: - IllegalArgumentException : if authorizationResponseURL is null/empty, or a malformed URL - AccessDeniedException : if the user has denied the authorization request - UnsupportedResponseTypeException : if the response Type isn't supported (note that this won't really happen in current implementation) - InvalidScopeException : if some of the specified scopes are invalid - OAuthAuthorizationCodeException : if any other error occurred during the operation

NewAuthorizationURL ( IEnumerable scopes, string state ) : string

Generate a new authorization URL. Exceptions: - IllegalArgumentException : if scopes is null/empty

OAuthFlowImpl ( string clientId, string clientSecret, string redirectURL, string authorizationURL, string tokenURL, Api.Internal.Http.HttpClient httpClient, Api.Internal.Json.JsonSerializer jsonSerializer ) : System

Constructor. Exceptions: -

ObtainNewToken ( Api.OAuth.AuthorizationResult authorizationResult ) : Api.OAuth.Token

Obtain a new token using AuthorizationResult. Exceptions: - IllegalArgumentException : if authorizationResult is null - InvalidTokenRequestException : if the token request is invalid (note that this won't really happen in current implementation) - InvalidOAuthClientException : if the client information is invalid - InvalidOAuthGrantException : if the authorization Code or refresh token is invalid or expired, the redirect_uri does not match, or the hash Value does not match the client secret and/or Code - UnsupportedOAuthGrantTypeException : if the grant Type is invalid (note that this won't really happen in current implementation) - OAuthTokenException : if any other error occurred during the operation

RefreshToken ( Api.OAuth.Token token ) : Api.OAuth.Token

Refresh token. Exceptions: - IllegalArgumentException : if token is null. - InvalidTokenRequestException : if the token request is invalid - InvalidOAuthClientException : if the client information is invalid - InvalidOAuthGrantException : if the authorization Code or refresh token is invalid or expired, the redirect_uri does not match, or the hash Value does not match the client secret and/or Code - UnsupportedOAuthGrantTypeException : if the grant Type is invalid - OAuthTokenException : if any other error occurred during the operation

RevokeToken ( Api.OAuth.Token token ) : void

Revoke token.

Protected Methods

Method Description
GenerateURL ( string baseURL, string>.IDictionary parameters ) : string

Helper function To generate a URL using the base URL and the given parameters. It will encode each of the parameters as well.

Private Methods

Method Description
RequestToken ( string url ) : Api.OAuth.Token

Request a token. Exceptions: - IllegalArgumentException : if Url is null or empty - InvalidTokenRequestException : if the token request is invalid - InvalidOAuthClientException : if the client information is invalid - InvalidOAuthGrantException : if the authorization Code or refresh token is invalid or expired, the redirect_uri does not match, or the hash Value does not match the client secret and/or Code - UnsupportedOAuthGrantTypeException : if the grant Type is invalid - OAuthTokenException : if any other error occurred during the operation

getHash ( string str ) : string

Method Details

ExtractAuthorizationResult() public method

Extract AuthorizationResult from the authorization response URL (i.e. the RedirectURL with the response parameters from Smartsheet OAuth server). Exceptions: - IllegalArgumentException : if authorizationResponseURL is null/empty, or a malformed URL - AccessDeniedException : if the user has denied the authorization request - UnsupportedResponseTypeException : if the response Type isn't supported (note that this won't really happen in current implementation) - InvalidScopeException : if some of the specified scopes are invalid - OAuthAuthorizationCodeException : if any other error occurred during the operation
the URI syntax exception the o auth authorization Code exception
public ExtractAuthorizationResult ( string authorizationResponseURL ) : Api.OAuth.AuthorizationResult
authorizationResponseURL string the authorization response URL
return Api.OAuth.AuthorizationResult

GenerateURL() protected method

Helper function To generate a URL using the base URL and the given parameters. It will encode each of the parameters as well.
protected GenerateURL ( string baseURL, string>.IDictionary parameters ) : string
baseURL string The base URL that the parameters will be appended To.
parameters string>.IDictionary The parameters that will be appended To the base URL. Each parameter will be URL encoded.
return string

NewAuthorizationURL() public method

Generate a new authorization URL. Exceptions: - IllegalArgumentException : if scopes is null/empty
public NewAuthorizationURL ( IEnumerable scopes, string state ) : string
scopes IEnumerable the scopes
state string an arbitrary string that will be returned To your app; intended To be used by you To ensure that /// this redirect is indeed from an OAuth flow that you initiated
return string

OAuthFlowImpl() public method

Constructor. Exceptions: -
If any argument is null, or empty string.
public OAuthFlowImpl ( string clientId, string clientSecret, string redirectURL, string authorizationURL, string tokenURL, Api.Internal.Http.HttpClient httpClient, Api.Internal.Json.JsonSerializer jsonSerializer ) : System
clientId string the client Id
clientSecret string the client secret
redirectURL string the redirect Url
authorizationURL string the authorization Url
tokenURL string the token Url
httpClient Api.Internal.Http.HttpClient the http client
jsonSerializer Api.Internal.Json.JsonSerializer the Json serializer
return System

ObtainNewToken() public method

Obtain a new token using AuthorizationResult. Exceptions: - IllegalArgumentException : if authorizationResult is null - InvalidTokenRequestException : if the token request is invalid (note that this won't really happen in current implementation) - InvalidOAuthClientException : if the client information is invalid - InvalidOAuthGrantException : if the authorization Code or refresh token is invalid or expired, the redirect_uri does not match, or the hash Value does not match the client secret and/or Code - UnsupportedOAuthGrantTypeException : if the grant Type is invalid (note that this won't really happen in current implementation) - OAuthTokenException : if any other error occurred during the operation
the o auth token exception the JSON serializer exception the URI syntax exception the invalid request exception
public ObtainNewToken ( Api.OAuth.AuthorizationResult authorizationResult ) : Api.OAuth.Token
authorizationResult Api.OAuth.AuthorizationResult the authorization RequestResult
return Api.OAuth.Token

RefreshToken() public method

Refresh token. Exceptions: - IllegalArgumentException : if token is null. - InvalidTokenRequestException : if the token request is invalid - InvalidOAuthClientException : if the client information is invalid - InvalidOAuthGrantException : if the authorization Code or refresh token is invalid or expired, the redirect_uri does not match, or the hash Value does not match the client secret and/or Code - UnsupportedOAuthGrantTypeException : if the grant Type is invalid - OAuthTokenException : if any other error occurred during the operation
the o auth token exception the JSON serializer exception the URI syntax exception the invalid request exception
public RefreshToken ( Api.OAuth.Token token ) : Api.OAuth.Token
token Api.OAuth.Token the token To refresh
return Api.OAuth.Token

RevokeToken() public method

Revoke token.
the o auth token exception the JSON serializer exception the URI syntax exception the invalid request exception if any other error occurred during the operation
public RevokeToken ( Api.OAuth.Token token ) : void
token Api.OAuth.Token the token
return void