/// <summary> /// Gets the URL to generate authorization code. /// </summary> /// <param name="appId">Application ID.</param> /// <param name="redirectUri">Redirect URL configured.</param> /// <param name="requestOptions"><see cref="RequestOptions"/>.</param> /// <returns>A task whose the result is the URL to obtain the authorization code.</returns> /// <exception cref="MercadoPagoException">If a unexpected exception occurs.</exception> /// <exception cref="MercadoPagoApiException">If the API returns a error.</exception> public string GetAuthorizationURL( string appId, string redirectUri, RequestOptions requestOptions = null) { Resource.User.User user = userClient.Get(requestOptions); if (user == null || string.IsNullOrEmpty(user.CountryId)) { return(null); } return(new StringBuilder() .Append("https://auth.mercadopago.com.") .Append(user.CountryId.ToLowerInvariant()) .Append("/authorization?client_id=") .Append(appId) .Append("&response_type=code&platform_id=mp&redirect_uri=") .Append(redirectUri) .ToString()); }
/// <summary> /// Gets async the URL to generate authorization code. /// </summary> /// <param name="appId">Application ID</param> /// <param name="redirectUri">Redirect URL configured</param> /// <param name="requestOptions"><see cref="RequestOptions"/></param> /// <param name="cancellationToken">Cancellation token</param> /// <returns>A task whose the result is the URL to obtain the authorization code.</returns> /// <exception cref="MercadoPagoException">If a unexpected exception occurs.</exception> /// <exception cref="MercadoPagoApiException">If the API returns a error.</exception> public async Task <string> GetAuthorizationURLAsync( string appId, string redirectUri, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) { Resource.User.User user = await userClient.GetAsync(requestOptions, cancellationToken); if (user == null || string.IsNullOrEmpty(user.CountryId)) { return(null); } return(new StringBuilder() .Append("https://auth.mercadopago.com.") .Append(user.CountryId.ToLowerInvariant()) .Append("/authorization?client_id=") .Append(appId) .Append("&response_type=code&platform_id=mp&redirect_uri=") .Append(redirectUri) .ToString()); }