Class OAuthClient
Client with methods to create a OAuth Credential.
Inherited Members
Namespace: MercadoPago.Client.OAuth
Assembly: MercadoPago.dll
Syntax
public class OAuthClient : MercadoPagoClient<OAuthCredential>
Constructors
| Edit this page View SourceOAuthClient()
Initializes a new instance of the OAuthClient class.
Declaration
public OAuthClient()
OAuthClient(IHttpClient)
Initializes a new instance of the OAuthClient class.
Declaration
public OAuthClient(IHttpClient httpClient)
Parameters
Type | Name | Description |
---|---|---|
IHttpClient | httpClient | The http client that will be used in HTTP requests. |
OAuthClient(IHttpClient, ISerializer)
Initializes a new instance of the OAuthClient class.
Declaration
public OAuthClient(IHttpClient httpClient, ISerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
IHttpClient | httpClient | The http client that will be used in HTTP requests. |
ISerializer | serializer | The serializer that will be used to serialize the HTTP requests content and to deserialize the HTTP response content. |
OAuthClient(ISerializer)
Initializes a new instance of the OAuthClient class.
Declaration
public OAuthClient(ISerializer serializer)
Parameters
Type | Name | Description |
---|---|---|
ISerializer | serializer | The serializer that will be used to serialize the HTTP requests content and to deserialize the HTTP response content. |
Methods
| Edit this page View SourceCreateOAuthCredential(string, string, RequestOptions)
Creates an OAuth credentials using access token as client secret.
Declaration
public OAuthCredential CreateOAuthCredential(string authorizationCode, string redirectUri, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
string | authorizationCode | Authorization code. |
string | redirectUri | Redirect Uri. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
OAuthCredential | The OAuth credential. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
CreateOAuthCredential(string, string, string, string, RequestOptions)
Creates an OAuth credentials with client id and client secret.
Declaration
public OAuthCredential CreateOAuthCredential(string authorizationCode, string clientId, string clientSecret, string redirectUri, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
string | authorizationCode | Authorization code. |
string | clientId | Client Id. |
string | clientSecret | Client Secret. |
string | redirectUri | Redirect Uri. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
OAuthCredential | The OAuth credential. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
CreateOAuthCredentialAsync(string, string, RequestOptions, CancellationToken)
Creates an OAuth credentials asynchronously using access token as client secret.
Declaration
public Task<OAuthCredential> CreateOAuthCredentialAsync(string authorizationCode, string redirectUri, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | authorizationCode | Authorization code. |
string | redirectUri | Redirect Uri. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<OAuthCredential> | A task whose the result is the OAuth credential. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
CreateOAuthCredentialAsync(string, string, string, string, RequestOptions, CancellationToken)
Creates an OAuth credentials asynchronously with client id and client secret.
Declaration
public Task<OAuthCredential> CreateOAuthCredentialAsync(string authorizationCode, string clientId, string clientSecret, string redirectUri, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | authorizationCode | Authorization code. |
string | clientId | Client Id. |
string | clientSecret | Client Secret. |
string | redirectUri | Redirect Uri. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<OAuthCredential> | A task whose the result is the OAuth credential. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
GetAuthorizationURL(string, string, RequestOptions)
Gets the URL to generate authorization code.
Declaration
public string GetAuthorizationURL(string appId, string redirectUri, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
string | appId | Application ID. |
string | redirectUri | Redirect URL configured. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
string | A task whose the result is the URL to obtain the authorization code. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
GetAuthorizationURLAsync(string, string, RequestOptions, CancellationToken)
Gets async the URL to generate authorization code.
Declaration
public Task<string> GetAuthorizationURLAsync(string appId, string redirectUri, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | appId | Application ID |
string | redirectUri | Redirect URL configured |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token |
Returns
Type | Description |
---|---|
Task<string> | A task whose the result is the URL to obtain the authorization code. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
RefreshOAuthCredential(string, RequestOptions)
Refresh OAuth credential.
Declaration
public OAuthCredential RefreshOAuthCredential(string refreshToken, RequestOptions requestOptions = null)
Parameters
Type | Name | Description |
---|---|---|
string | refreshToken | Refresh token. |
RequestOptions | requestOptions |
Returns
Type | Description |
---|---|
OAuthCredential | The refreshed OAuth credential. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |
RefreshOAuthCredentialAsync(string, RequestOptions, CancellationToken)
Refresh OAuth credential async.
Declaration
public Task<OAuthCredential> RefreshOAuthCredentialAsync(string refreshToken, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | refreshToken | Refresh token. |
RequestOptions | requestOptions | |
CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
Task<OAuthCredential> | A task whose the result is the refreshed OAuth credential. |
Exceptions
Type | Condition |
---|---|
MercadoPagoException | If a unexpected exception occurs. |
MercadoPagoApiException | If the API returns a error. |