Package com.mercadopago.client.oauth
Class OauthClient
- java.lang.Object
-
- com.mercadopago.client.MercadoPagoClient
-
- com.mercadopago.client.oauth.OauthClient
-
public class OauthClient extends MercadoPagoClient
Client responsible for performing oauth authorization.
-
-
Field Summary
-
Fields inherited from class com.mercadopago.client.MercadoPagoClient
defaultHeaders, httpClient
-
-
Constructor Summary
Constructors Constructor Description OauthClient()Default constructor.OauthClient(MPHttpClient httpClient)Constructor used for providing a custom http client.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CreateOauthCredentialcreateCredential(String authorizationCode, String redirectUri)Create Oauth credentials to operate on behalf of a seller.CreateOauthCredentialcreateCredential(String authorizationCode, String redirectUri, MPRequestOptions requestOptions)Create Oauth credentials to operate on behalf of a seller.StringgetAuthorizationURL(String appId, String redirectUri)Get URL for Oauth authorization.StringgetAuthorizationURL(String appId, String redirectUri, MPRequestOptions requestOptions)Get URL for Oauth authorization.RefreshOauthCredentialrefreshCredential(String refreshToken)Refresh Oauth credentials.RefreshOauthCredentialrefreshCredential(String refreshToken, MPRequestOptions requestOptions)Refresh Oauth credentials.
-
-
-
Constructor Detail
-
OauthClient
public OauthClient()
Default constructor. Uses the default http client used by the SDK.
-
OauthClient
public OauthClient(MPHttpClient httpClient)
Constructor used for providing a custom http client.- Parameters:
httpClient- http client
-
-
Method Detail
-
getAuthorizationURL
public String getAuthorizationURL(String appId, String redirectUri) throws MPException, MPApiException
Get URL for Oauth authorization.- Parameters:
appId- Id of the appredirectUri- URL for redirection after authorization- Returns:
- URL to perform authorization
- Throws:
MPException- an error if the request failsMPApiException
-
getAuthorizationURL
public String getAuthorizationURL(String appId, String redirectUri, MPRequestOptions requestOptions) throws MPException, MPApiException
Get URL for Oauth authorization.- Parameters:
appId- Id of the appredirectUri- URL for redirection after authorizationrequestOptions- metadata to customize the request- Returns:
- URL to perform authorization
- Throws:
MPException- an error if the request failsMPApiException
-
createCredential
public CreateOauthCredential createCredential(String authorizationCode, String redirectUri) throws MPException, MPApiException
Create Oauth credentials to operate on behalf of a seller. Go here to learn more.- Parameters:
authorizationCode- authorization code received from calling getAuthorizationURLredirectUri- the redirectUri received from calling getAuthorizationURL- Returns:
- the Oauth credentials
- Throws:
MPException- an error if the request failsMPApiException- See Also:
- api docs
-
createCredential
public CreateOauthCredential createCredential(String authorizationCode, String redirectUri, MPRequestOptions requestOptions) throws MPException, MPApiException
Create Oauth credentials to operate on behalf of a seller. Go here to learn more.- Parameters:
authorizationCode- authorization code received from calling getAuthorizationURLredirectUri- the redirectUri received from calling getAuthorizationURLrequestOptions- metadata to customize the request- Returns:
- the Oauth credentials
- Throws:
MPException- an error if the request failsMPApiException- See Also:
- api docs
-
refreshCredential
public RefreshOauthCredential refreshCredential(String refreshToken) throws MPException, MPApiException
Refresh Oauth credentials.- Parameters:
refreshToken- refresh token received when you create credentials- Returns:
- new Oauth credentials
- Throws:
MPException- an error if the request failsMPApiException- See Also:
- api docs
-
refreshCredential
public RefreshOauthCredential refreshCredential(String refreshToken, MPRequestOptions requestOptions) throws MPException, MPApiException
Refresh Oauth credentials.- Parameters:
refreshToken- refresh token received when you create credentialsrequestOptions- metadata to customize the request- Returns:
- new Oauth credentials
- Throws:
MPException- an error if the request failsMPApiException- See Also:
- api docs
-
-