diff --git a/src/MercadoPago/Client/OAuth/CreateOAuthCredentialRequest.cs b/src/MercadoPago/Client/OAuth/CreateOAuthCredentialRequest.cs index 93bda5b0..2eb0458b 100644 --- a/src/MercadoPago/Client/OAuth/CreateOAuthCredentialRequest.cs +++ b/src/MercadoPago/Client/OAuth/CreateOAuthCredentialRequest.cs @@ -1,4 +1,4 @@ -namespace MercadoPago.Client.OAuth +namespace MercadoPago.Client.OAuth { /// /// Data to create an OAuth credential. @@ -6,7 +6,12 @@ public class CreateOAuthCredentialRequest { /// - /// Client secret (Access Token). + /// Client Id + /// + public string ClientId { get; set; } + + /// + /// Client secret /// public string ClientSecret { get; set; } diff --git a/src/MercadoPago/Client/OAuth/OAuthClient.cs b/src/MercadoPago/Client/OAuth/OAuthClient.cs index 4273eadf..07d7e3d1 100644 --- a/src/MercadoPago/Client/OAuth/OAuthClient.cs +++ b/src/MercadoPago/Client/OAuth/OAuthClient.cs @@ -1,4 +1,4 @@ -namespace MercadoPago.Client.OAuth +namespace MercadoPago.Client.OAuth { using System.Text; using System.Threading; @@ -122,9 +122,9 @@ public string GetAuthorizationURL( .Append(redirectUri) .ToString(); } - /// - /// Creates async an OAuth credentials. + /// Creates an OAuth credentials asynchronously using + /// access token as client secret. /// /// Authorization code. /// Redirect Uri. @@ -165,7 +165,44 @@ public Task CreateOAuthCredentialAsync( } /// - /// Creates an OAuth credentials. + /// Creates an OAuth credentials asynchronously with + /// client id and client secret. + /// + /// Authorization code. + /// Client Id. + /// Client Secret. + /// Redirect Uri. + /// . + /// Cancellation token. + /// A task whose the result is the OAuth credential. + /// If a unexpected exception occurs. + /// If the API returns a error. + public Task CreateOAuthCredentialAsync( + string authorizationCode, + string clientId, + string clientSecret, + string redirectUri, + RequestOptions requestOptions = null, + CancellationToken cancellationToken = default) + { + var request = new CreateOAuthCredentialRequest + { + ClientId = clientId, + ClientSecret = clientSecret, + Code = authorizationCode, + RedirectUri = redirectUri, + }; + return SendAsync( + "/oauth/token", + HttpMethod.POST, + request, + requestOptions, + cancellationToken); + } + + /// + /// Creates an OAuth credentials using + /// access token as client secret. /// /// Authorization code. /// Redirect Uri. @@ -202,6 +239,39 @@ public OAuthCredential CreateOAuthCredential( requestOptions); } + /// + /// Creates an OAuth credentials with + /// client id and client secret. + /// + /// Authorization code. + /// Client Id. + /// Client Secret. + /// Redirect Uri. + /// . + /// The OAuth credential. + /// If a unexpected exception occurs. + /// If the API returns a error. + public OAuthCredential CreateOAuthCredential( + string authorizationCode, + string clientId, + string clientSecret, + string redirectUri, + RequestOptions requestOptions = null) + { + var request = new CreateOAuthCredentialRequest + { + ClientId = clientId, + ClientSecret = clientSecret, + Code = authorizationCode, + RedirectUri = redirectUri, + }; + return Send( + "/oauth/token", + HttpMethod.POST, + request, + requestOptions); + } + /// /// Refresh OAuth credential async. ///