All URIs are relative to https://connect.squareup.com
Method | HTTP request | Description |
---|---|---|
obtainToken | POST /oauth2/token | ObtainToken |
renewToken | POST /oauth2/clients/{client_id}/access-token/renew | RenewToken |
revokeToken | POST /oauth2/revoke | RevokeToken |
ObtainTokenResponse obtainToken(body)
ObtainToken
Returns an OAuth access token. The endpoint supports distinct methods of obtaining OAuth access tokens. Applications specify a method by adding the `grant_type` parameter in the request and also provide relevant information. For more information, see OAuth access token management. Note: Regardless of the method application specified, the endpoint always returns two items; an OAuth access token and a refresh token in the response. OAuth tokens should only live on secure servers. Application clients should never interact directly with OAuth tokens.
// Import classes:
//import com.squareup.connect.ApiException;
//import com.squareup.connect.api.OAuthApi;
OAuthApi apiInstance = new OAuthApi();
ObtainTokenRequest body = new ObtainTokenRequest(); // ObtainTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
ObtainTokenResponse result = apiInstance.obtainToken(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OAuthApi#obtainToken");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
body | ObtainTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
No authorization required
- Content-Type: application/json
- Accept: application/json
RenewTokenResponse renewToken(clientId, body)
RenewToken
`RenewToken` is deprecated. For information about refreshing OAuth access tokens, see Renew OAuth Token. Renews an OAuth access token before it expires. OAuth access tokens besides your application's personal access token expire after 30 days. You can also renew expired tokens within 15 days of their expiration. You cannot renew an access token that has been expired for more than 15 days. Instead, the associated user must re-complete the OAuth flow from the beginning. Important: The `Authorization` header for this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with the application secret on the Credentials page in the application dashboard.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.OAuthApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure API key authorization: oauth2ClientSecret
ApiKeyAuth oauth2ClientSecret = (ApiKeyAuth) defaultClient.getAuthentication("oauth2ClientSecret");
oauth2ClientSecret.setApiKey("APPLICATION SECRET");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
oauth2ClientSecret.setApiKeyPrefix("Client");
OAuthApi apiInstance = new OAuthApi();
String clientId = "clientId_example"; // String | Your application's ID, available from the [application dashboard](https://connect.squareup.com/apps).
RenewTokenRequest body = new RenewTokenRequest(); // RenewTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
RenewTokenResponse result = apiInstance.renewToken(clientId, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OAuthApi#renewToken");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
clientId | String | Your application's ID, available from the application dashboard. | |
body | RenewTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
- Content-Type: application/json
- Accept: application/json
RevokeTokenResponse revokeToken(body)
RevokeToken
Revokes an access token generated with the OAuth flow. If an account has more than one OAuth access token for your application, this endpoint revokes all of them, regardless of which token you specify. When an OAuth access token is revoked, all of the active subscriptions associated with that OAuth token are canceled immediately. Important: The `Authorization` header for this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with the application secret on the Credentials page in the application dashboard.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.OAuthApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure API key authorization: oauth2ClientSecret
ApiKeyAuth oauth2ClientSecret = (ApiKeyAuth) defaultClient.getAuthentication("oauth2ClientSecret");
oauth2ClientSecret.setApiKey("APPLICATION SECRET");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
oauth2ClientSecret.setApiKeyPrefix("Client");
OAuthApi apiInstance = new OAuthApi();
RevokeTokenRequest body = new RevokeTokenRequest(); // RevokeTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
RevokeTokenResponse result = apiInstance.revokeToken(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OAuthApi#revokeToken");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
body | RevokeTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
- Content-Type: application/json
- Accept: application/json