/// <summary>
/// Class containing access token and related information.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class AccessToken
{
internal AccessToken()
/// <summary>
/// The lifetime in seconds of the access token.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public long ExpiresIn { get; internal set;}
/// <summary>
/// The access token issued by the authorization server.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Token { get; internal set;}
/// <summary>
/// The scope of the access token.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public IEnumerable<string> Scope { get; internal set;}
/// <summary>
/// The type of the access token.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string TokenType { get; internal set;}
}
}
/// Enumerations for Client authentication scheme, used to sign client id and client secret accordingly.
/// Default is Basic (http://tools.ietf.org/html/rfc2617#section-2)
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <remarks>Facebook and Google does not support HTTP Basic Authentication, instead they require client credentials to be sent via request body.</remarks>
public enum AuthenticationScheme
{
/// <summary>
/// HTTP Basic Authentication for client authentication
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
Basic = 0,
/// <summary>
/// HTTP Basic Authentication for client authentication
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
Digest,
/// <summary>
/// Client credentials are sent via request body
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
RequestBody
}
}
/// <summary>
/// The request parameters to be sent to authorization end point.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public abstract class AuthorizationRequest
{
/// <summary>
/// The desired response type from the OAuth authorization end point.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public abstract string ResponseType { get; }
/// <summary>
/// Client secret credentials.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public ClientCredentials ClientSecrets { get; set; }
/// <summary>
/// The scope of the access.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public IEnumerable<string> Scopes { get; set; }
/// <summary>
/// The authorization end point URL.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public Uri AuthorizationEndpoint { get; set; }
/// <summary>
/// The redirection endpoint of the auhorization flow.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public Uri RedirectionEndPoint { get; set; }
/// <summary>
/// The access token end point URL.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public Uri TokenEndpoint { get; set; }
/// <summary>
/// The client's state which is maintained between request and response.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string State { get; set; }
/// <summary>
/// Custom key-value parameters to be sent to the server
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public IEnumerable<KeyValuePair<string, string>> CustomData { get; set; }
}
}
/// <summary>
/// The response containing authroization code from the authorization server.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class AuthorizationResponse : IDisposable
{
private bool _disposed = false;
/// <summary>
/// Destructor of the AuthorizationResponse class.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
~AuthorizationResponse()
{
Dispose(false);
/// <summary>
/// The authroization code.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Code { get; internal set; }
/// <summary>
/// The state parameter present in authorization request.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <remarks>
/// The value can be null depending on the server specifications.
/// </remarks>
/// <summary>
/// Custom key-value parameter received from service provider
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <remarks>
/// The return value can be null depending on the server specifications.
/// </remarks>
/// <summary>
/// Releases any unmanaged resources used by this object.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public void Dispose()
{
Dispose(true);
/// <summary>
/// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
protected virtual void Dispose(bool disposing)
{
/// Refer to http://tools.ietf.org/html/rfc6749 about OAuth 2.0 protocols.
/// Also service provider document needs to be referred for using end points and additional parameters.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public abstract class Authorizer : IDisposable
{
/// <summary>
/// Constructor for Authoirzer instances
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public Authorizer()
{
int ret = Interop.Manager.Create(out _managerHandle);
/// <summary>
/// Destructor of the Authorizer class.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
~Authorizer()
{
Dispose(false);
/// <summary>
/// Indicates if the current instance is already handling an authorization request
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public bool IsRequestInProgress
{
get
/// <summary>
/// Authorizes the client with access toekn / authorizaion code in Implicit and Authorization Code grant flows respectively.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <see cref="CodeGrantAuthorizer.AuthorizeAsync(AuthorizationRequest)"/>
/// <see cref="ImplicitGrantAuthorizer.AuthorizeAsync(AuthorizationRequest)"/>
/// <param name="request">An authorization request</param>
/// <summary>
/// Gets the access token in OAuth2 supported grant flows except Implicit Grant flow.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <see cref="CodeGrantAuthorizer.AuthorizeAsync(AuthorizationRequest)"/>
/// <see cref="ImplicitGrantAuthorizer.AuthorizeAsync(AuthorizationRequest)"/>
/// <param name="request">A token request</param>
/// <summary>
/// Releases any unmanaged resources used by this object.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public void Dispose()
{
Dispose(true);
/// <summary>
/// Retrieves access token using a refresh token.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <param name="request">Request containing refresh token</param>
/// <returns>The response containing access token.</returns>
/// <privilege>http://tizen.org/privilege/internet</privilege>
/// <summary>
/// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
protected virtual void Dispose(bool disposing)
{
/// <summary>
/// Contains client credentials required for authentication in request-body
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class ClientCredentials
{
/// <summary>
/// The constructor
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public ClientCredentials()
{
/// <summary>
/// The client identifier
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Id { get; set; }
/// <summary>
/// The client secret
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Secret { get; set; }
}
}
/// <summary>
/// The ClientCredentialsAuthorizer is used to obtain access tokens using Client Credentials Grant flow as described at https://tools.ietf.org/html/rfc6749#section-4.4
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class ClientCredentialsAuthorizer : Authorizer
{
/// <summary>
/// The constructor
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public ClientCredentialsAuthorizer()
{
/// <summary>
/// Authorization not supported through this API for this flow.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <exception cref="InvalidOperationException">Thrown when the operation is not supported</exception>
public override Task<AuthorizationResponse> AuthorizeAsync(AuthorizationRequest request)
{
/// <summary>
/// Refreshing access token is not supported in this flow.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <exception cref="InvalidOperationException">Thrown when the operation is not supported</exception>
public override Task<TokenResponse> RefreshAccessTokenAsync(RefreshTokenRequest request)
{
/// Retrieves access token using client credentials.
/// The authroization request parameters should be as defined in https://tools.ietf.org/html/rfc6749#section-4.4.2
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <param name="request">The token request <see cref="ClientCredentialsTokenRequest"/></param>
/// <returns>The response containing access token.</returns>
/// <privilege>http://tizen.org/privilege/internet</privilege>
/// <summary>
/// The class contains request parameters for retreiving access token in Client Credentials Grant flow.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class ClientCredentialsTokenRequest : TokenRequest
{
/// <summary>
/// The constructor
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public ClientCredentialsTokenRequest()
{
/// <summary>
/// The grant type.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public override string GrantType { get; } = "client_credentials";
}
}
/// <summary>
/// The constructor
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public CodeGrantAuthorizationRequest()
{
/// <summary>
/// The response type parameter to authorization server.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public override string ResponseType { get; } = "code";
}
}
/// <summary>
/// The CodeGrantAuthorizer is used to obtain access tokens and refresh tokens using Authorization Code Grant flow as described at https://tools.ietf.org/html/rfc6749#section-4.1
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class CodeGrantAuthorizer : Authorizer
{
/// <summary>
/// The constructor
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public CodeGrantAuthorizer()
{
/// <summary>
/// Retrieves authorization code asynchronously. The authroization request parameters should be as defined in https://tools.ietf.org/html/rfc6749#section-4.1.1
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <param name="request">The authorization request <see cref="CodeGrantAuthorizationRequest"/></param>
/// <returns>The response containing authorization code.</returns>
/// <privilege>http://tizen.org/privilege/internet</privilege>
/// Retrieves access token by exchanging authorization code received using <see cref="AuthorizeAsync(AuthorizationRequest)"/>.
/// The authroization request parameters should be as defined in https://tools.ietf.org/html/rfc6749#section-4.1.3
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <param name="request">The token request <see cref="CodeGrantTokenRequest"/></param>
/// <returns>The response containing access token.</returns>
/// <privilege>http://tizen.org/privilege/internet</privilege>
/// <summary>
/// Clears the cookies
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public void ClearCookies()
{
int ret = (int)OAuth2Error.None;
/// <summary>
/// Clear the cache
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public void ClearCache()
{
int ret = (int)OAuth2Error.None;
/// <summary>
/// The class contains request parameters for retreiving access token in Authorization Code Grant flow.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class CodeGrantTokenRequest : TokenRequest
{
/// <summary>
/// The constructor
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public CodeGrantTokenRequest()
{
/// <summary>
/// The grant type
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public override string GrantType { get; } = "authorization_code";
/// <summary>
/// The authoriztion code received from the authorization server.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Code { get; set; }
}
}
/// <summary>
/// The constructor
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public ImplicitGrantAuthorizationRequest()
{
/// <summary>
/// The response type parameter to aturhoization server.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public override string ResponseType { get; } = "token";
}
}
/// <summary>
/// The ImplicitGrantAuthorizer is used to obtain access tokens using Implicit Grant flow as described at https://tools.ietf.org/html/rfc6749#section-4.2
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class ImplicitGrantAuthorizer : Authorizer
{
/// <summary>
/// The constructor
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public ImplicitGrantAuthorizer()
{
/// <summary>
/// Retrieves access token asynchronously. The authroization request parameters should be as defined in https://tools.ietf.org/html/rfc6749#section-4.2.1
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <param name="request">The authorization request <see cref="ImplicitGrantAuthorizationRequest"/></param>
/// <returns>The response containing access token.</returns>
/// <privilege>http://tizen.org/privilege/internet</privilege>
/// <summary>
/// Access token can be retreived implicitly using <see cref="AuthorizeAsync"/> in this flow.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <exception cref="InvalidOperationException">Thrown when the operation is not supported</exception>
public override Task<TokenResponse> GetAccessTokenAsync(TokenRequest request)
{
/// <summary>
/// Refreshing access token is not supported in this flow.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <exception cref="InvalidOperationException">Thrown when the operation is not supported</exception>
public override Task<TokenResponse> RefreshAccessTokenAsync(RefreshTokenRequest request)
{
/// <summary>
/// The error response.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public OAuth2ErrorResponse Error { get; internal set; }
}
/// <summary>
/// Wrapper class contaning OAuth2 related error information
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class OAuth2ErrorResponse
{
internal OAuth2ErrorResponse ()
/// <summary>
/// The server error code
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public int ServerErrorCode { get; internal set; }
/// <summary>
/// The platform error cocde
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public int PlatformErrorCode { get; internal set; }
/// <summary>
/// Error description
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Error { get; internal set; }
/// <summary>
/// URI of the error page.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string ErrorUri { get; internal set; }
}
}
/// <summary>
/// The refresh token which can be used to obtain new access token.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class RefreshToken
{
internal RefreshToken ()
/// <summary>
/// The refresh token issued to the client.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Token { get; internal set; }
}
}
/// <summary>
/// The class contains request parameters for refreshing an access token.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class RefreshTokenRequest : TokenRequest
{
/// <summary>
/// The constructor
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public RefreshTokenRequest()
{
/// <summary>
/// The grant type to be used
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public override string GrantType { get; } = "refresh_token";
/// <summary>
/// The refresh token issued by authorization server.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string RefreshToken { get; set; }
}
}
/// <summary>
/// The ResourceOwnerPwdCredentialsAuthorizer is used to obtain access tokens using Resource Owner Password Credentials Grant flow as described at https://tools.ietf.org/html/rfc6749#section-4.3
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class ResourceOwnerPwdCredentialsAuthorizer : Authorizer
{
/// <summary>
/// The constructor
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public ResourceOwnerPwdCredentialsAuthorizer()
{
/// <summary>
/// Authorization not supported through this API for this flow.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <exception cref="InvalidOperationException">Thrown when the operation is not supported</exception>
public override Task<AuthorizationResponse> AuthorizeAsync(AuthorizationRequest request)
{
/// Retrieves access token by sending resource owner's password credentials.
/// The authroization request parameters should be as defined in https://tools.ietf.org/html/rfc6749#section-4.3.2
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <param name="request">The token request <see cref="ResourceOwnerPwdCredentialsTokenRequest"/></param>
/// <returns>The response containing access token.</returns>
/// <privilege>http://tizen.org/privilege/internet</privilege>
/// <summary>
/// The class contains request parameters for retreiving access token in Resource Owner Password Credentials Grant flow.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class ResourceOwnerPwdCredentialsTokenRequest : TokenRequest
{
/// <summary>
/// <summary>
/// The grant type
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public override string GrantType { get; } = "password";
/// <summary>
/// The resource owner username
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Username { get; set; }
/// <summary>
/// The resource owner password
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string Password { get; set; }
}
}
/// <summary>
/// Abstract wrapper class containing OAuth 2.0 request parameters for requesting an access token.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public abstract class TokenRequest
{
/// <summary>
/// The Grant type
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public abstract string GrantType { get; }
/// <summary>
/// The client credentials
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public ClientCredentials ClientSecrets { get; set; }
/// <summary>
/// The access token end point URL.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public Uri TokenEndpoint { get; set; }
/// <summary>
/// The redirection endpoint of the auhorization flow.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public Uri RedirectionEndPoint { get; set; }
/// <summary>
/// The scope of the access request as described by https://tools.ietf.org/html/rfc6749#section-3.3
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public IEnumerable<string> Scopes { get; set; }
/// <summary>
/// Custom key-value parameters to be sent to the server
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public IEnumerable<KeyValuePair<string, string>> CustomData { get; set; }
/// <summary>
/// Client authentication scheme. Default is Basic
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public AuthenticationScheme AuthenticationScheme { get; set; } = AuthenticationScheme.Basic;
/// <summary>
/// The client's state which is maintained between request and response.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public string State { get; set; }
}
}
/// <summary>
/// The response from authroization server containing access token and an optional refresh token.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public class TokenResponse
{
private bool _disposed = false;
/// <summary>
/// Destructor of the AuthorizationResponse class.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
~TokenResponse()
{
Dispose(false);
/// <summary>
/// The access token
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public AccessToken AccessToken { get; internal set; }
/// <summary>
/// The state parameter present in authorization request.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <remarks>
/// The value can be null depending on the server specifications.
/// </remarks>
/// <summary>
/// The refresh token. The value will be null if authorization server doesn't return a refresh token.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <remarks>
/// Issuing a refresh token is optional at the discretion of the authorization server.
/// </remarks>
/// <summary>
/// Gets the value of the key received from service provider
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <returns>The value of respecitve key </returns>
/// <exception cref="System.ArgumentException">Thrown when the key does not exist or when there is an invalid parameter.</exception>
public string GetCustomValue(string key)
/// <summary>
/// Releases any unmanaged resources used by this object.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
public void Dispose()
{
Dispose(true);
/// <summary>
/// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
/// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
protected virtual void Dispose(bool disposing)
{