|
| 1 | +# SquareConnect::OAuthApi |
| 2 | + |
| 3 | +All URIs are relative to *https://connect.squareup.com* |
| 4 | + |
| 5 | +Method | HTTP request | Description |
| 6 | +------------- | ------------- | ------------- |
| 7 | +[**obtain_token**](OAuthApi.md#obtain_token) | **POST** /oauth2/token | ObtainToken |
| 8 | +[**renew_token**](OAuthApi.md#renew_token) | **POST** /oauth2/clients/{client_id}/access-token/renew | RenewToken |
| 9 | +[**revoke_token**](OAuthApi.md#revoke_token) | **POST** /oauth2/revoke | RevokeToken |
| 10 | + |
| 11 | + |
| 12 | +# **obtain_token** |
| 13 | +> ObtainTokenResponse obtain_token(body) |
| 14 | +
|
| 15 | +ObtainToken |
| 16 | + |
| 17 | +Exchanges the authorization code for an access token. After a merchant authorizes your application with the permissions form, an authorization code is sent to the application's redirect URL (See [Implementing OAuth](https://docs.connect.squareup.com/api/oauth#implementingoauth) for information about how to set up the redirect URL). |
| 18 | + |
| 19 | +### Example |
| 20 | +```ruby |
| 21 | +# load the gem |
| 22 | +require 'square_connect' |
| 23 | + |
| 24 | +api_instance = SquareConnect::OAuthApi.new |
| 25 | + |
| 26 | +body = SquareConnect::ObtainTokenRequest.new # ObtainTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
| 27 | + |
| 28 | + |
| 29 | +begin |
| 30 | + #ObtainToken |
| 31 | + result = api_instance.obtain_token(body) |
| 32 | + p result |
| 33 | +rescue SquareConnect::ApiError => e |
| 34 | + puts "Exception when calling OAuthApi->obtain_token: #{e}" |
| 35 | +end |
| 36 | +``` |
| 37 | + |
| 38 | +### Parameters |
| 39 | + |
| 40 | +Name | Type | Description | Notes |
| 41 | +------------- | ------------- | ------------- | ------------- |
| 42 | + **body** | [**ObtainTokenRequest**](ObtainTokenRequest.md)| An object containing the fields to POST for the request. See the corresponding object definition for field details. | |
| 43 | + |
| 44 | +### Return type |
| 45 | + |
| 46 | +[**ObtainTokenResponse**](ObtainTokenResponse.md) |
| 47 | + |
| 48 | +### Authorization |
| 49 | + |
| 50 | +No authorization required |
| 51 | + |
| 52 | +### HTTP request headers |
| 53 | + |
| 54 | + - **Content-Type**: application/json |
| 55 | + - **Accept**: application/json |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +# **renew_token** |
| 60 | +> RenewTokenResponse renew_token(client_id, body) |
| 61 | +
|
| 62 | +RenewToken |
| 63 | + |
| 64 | +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 merchant must complete the [OAuth flow](https://docs.connect.squareup.com/api/oauth#implementingoauth) from the beginning. __Important:__ The `Authorization` header you provide to this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with your application's secret, available from the [application dashboard](https://connect.squareup.com/apps). |
| 65 | + |
| 66 | +### Example |
| 67 | +```ruby |
| 68 | +# load the gem |
| 69 | +require 'square_connect' |
| 70 | +# setup authorization |
| 71 | +SquareConnect.configure do |config| |
| 72 | + # Configure API key authorization: oauth2ClientSecret |
| 73 | + config.api_key['Authorization'] = 'YOUR API KEY' |
| 74 | + # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) |
| 75 | + #config.api_key_prefix['Authorization'] = 'Bearer' |
| 76 | +end |
| 77 | + |
| 78 | +api_instance = SquareConnect::OAuthApi.new |
| 79 | + |
| 80 | +client_id = "client_id_example" # String | Your application's ID, available from the [application dashboard](https://connect.squareup.com/apps). |
| 81 | + |
| 82 | +body = SquareConnect::RenewTokenRequest.new # RenewTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
| 83 | + |
| 84 | + |
| 85 | +begin |
| 86 | + #RenewToken |
| 87 | + result = api_instance.renew_token(client_id, body) |
| 88 | + p result |
| 89 | +rescue SquareConnect::ApiError => e |
| 90 | + puts "Exception when calling OAuthApi->renew_token: #{e}" |
| 91 | +end |
| 92 | +``` |
| 93 | + |
| 94 | +### Parameters |
| 95 | + |
| 96 | +Name | Type | Description | Notes |
| 97 | +------------- | ------------- | ------------- | ------------- |
| 98 | + **client_id** | **String**| Your application's ID, available from the [application dashboard](https://connect.squareup.com/apps). | |
| 99 | + **body** | [**RenewTokenRequest**](RenewTokenRequest.md)| An object containing the fields to POST for the request. See the corresponding object definition for field details. | |
| 100 | + |
| 101 | +### Return type |
| 102 | + |
| 103 | +[**RenewTokenResponse**](RenewTokenResponse.md) |
| 104 | + |
| 105 | +### Authorization |
| 106 | + |
| 107 | +[oauth2ClientSecret](../README.md#oauth2ClientSecret) |
| 108 | + |
| 109 | +### HTTP request headers |
| 110 | + |
| 111 | + - **Content-Type**: application/json |
| 112 | + - **Accept**: application/json |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | +# **revoke_token** |
| 117 | +> RevokeTokenResponse revoke_token(body) |
| 118 | +
|
| 119 | +RevokeToken |
| 120 | + |
| 121 | +Revokes an access token generated with the OAuth flow. If a merchant has more than one access token for your application, this endpoint revokes all of them, regardless of which token you specify. If you revoke a merchant's access token, all of the merchant's active subscriptions associated with your application are canceled immediately. __Important:__ The `Authorization` header you provide to this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with your application's secret, available from the [application dashboard](https://connect.squareup.com/apps). |
| 122 | + |
| 123 | +### Example |
| 124 | +```ruby |
| 125 | +# load the gem |
| 126 | +require 'square_connect' |
| 127 | +# setup authorization |
| 128 | +SquareConnect.configure do |config| |
| 129 | + # Configure API key authorization: oauth2ClientSecret |
| 130 | + config.api_key['Authorization'] = 'YOUR API KEY' |
| 131 | + # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) |
| 132 | + #config.api_key_prefix['Authorization'] = 'Bearer' |
| 133 | +end |
| 134 | + |
| 135 | +api_instance = SquareConnect::OAuthApi.new |
| 136 | + |
| 137 | +body = SquareConnect::RevokeTokenRequest.new # RevokeTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
| 138 | + |
| 139 | + |
| 140 | +begin |
| 141 | + #RevokeToken |
| 142 | + result = api_instance.revoke_token(body) |
| 143 | + p result |
| 144 | +rescue SquareConnect::ApiError => e |
| 145 | + puts "Exception when calling OAuthApi->revoke_token: #{e}" |
| 146 | +end |
| 147 | +``` |
| 148 | + |
| 149 | +### Parameters |
| 150 | + |
| 151 | +Name | Type | Description | Notes |
| 152 | +------------- | ------------- | ------------- | ------------- |
| 153 | + **body** | [**RevokeTokenRequest**](RevokeTokenRequest.md)| An object containing the fields to POST for the request. See the corresponding object definition for field details. | |
| 154 | + |
| 155 | +### Return type |
| 156 | + |
| 157 | +[**RevokeTokenResponse**](RevokeTokenResponse.md) |
| 158 | + |
| 159 | +### Authorization |
| 160 | + |
| 161 | +[oauth2ClientSecret](../README.md#oauth2ClientSecret) |
| 162 | + |
| 163 | +### HTTP request headers |
| 164 | + |
| 165 | + - **Content-Type**: application/json |
| 166 | + - **Accept**: application/json |
| 167 | + |
| 168 | + |
| 169 | + |
0 commit comments