Class: SquareConnect::OAuthApi
- Inherits:
-
Object
- Object
- SquareConnect::OAuthApi
- Defined in:
- lib/square_connect/api/o_auth_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#initialize(api_client = ApiClient.default) ⇒ OAuthApi
constructor
A new instance of OAuthApi.
-
#obtain_token(body, opts = {}) ⇒ ObtainTokenResponse
ObtainToken Returns an OAuth access token.
-
#obtain_token_with_http_info(body, opts = {}) ⇒ Array<(ObtainTokenResponse, Fixnum, Hash)>
ObtainToken Returns an OAuth access token.
-
#renew_token(client_id, body, opts = {}) ⇒ RenewTokenResponse
RenewToken ‘RenewToken` is deprecated.
-
#renew_token_with_http_info(client_id, body, opts = {}) ⇒ Array<(RenewTokenResponse, Fixnum, Hash)>
RenewToken `RenewToken` is deprecated.
-
#revoke_token(body, opts = {}) ⇒ RevokeTokenResponse
RevokeToken Revokes an access token generated with the OAuth flow.
-
#revoke_token_with_http_info(body, opts = {}) ⇒ Array<(RevokeTokenResponse, Fixnum, Hash)>
RevokeToken Revokes an access token generated with the OAuth flow.
Constructor Details
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
14 15 16 |
# File 'lib/square_connect/api/o_auth_api.rb', line 14 def api_client @api_client end |
Instance Method Details
#obtain_token(body, opts = {}) ⇒ ObtainTokenResponse
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](/authz/oauth/how-it-works#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__.
25 26 27 28 |
# File 'lib/square_connect/api/o_auth_api.rb', line 25 def obtain_token(body, opts = {}) data, _status_code, _headers = obtain_token_with_http_info(body, opts) return data end |
#obtain_token_with_http_info(body, opts = {}) ⇒ Array<(ObtainTokenResponse, Fixnum, Hash)>
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](/authz/oauth/how-it-works#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__.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/square_connect/api/o_auth_api.rb', line 35 def obtain_token_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: OAuthApi.obtain_token ..." end # verify the required parameter 'body' is set fail ArgumentError, "Missing the required parameter 'body' when calling OAuthApi.obtain_token" if body.nil? # resource path local_var_path = "/oauth2/token".sub('{format}','json') # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-06-12" # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = [] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ObtainTokenResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: OAuthApi#obtain_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#renew_token(client_id, body, opts = {}) ⇒ RenewTokenResponse
RenewToken ‘RenewToken` is deprecated. For information about refreshing OAuth access tokens, see [Renew OAuth Token](developer.squareup.com/docs/oauth-api/cookbook/renew-oauth-tokens). 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](connect.squareup.com/apps).
81 82 83 84 |
# File 'lib/square_connect/api/o_auth_api.rb', line 81 def renew_token(client_id, body, opts = {}) data, _status_code, _headers = renew_token_with_http_info(client_id, body, opts) return data end |
#renew_token_with_http_info(client_id, body, opts = {}) ⇒ Array<(RenewTokenResponse, Fixnum, Hash)>
RenewToken `RenewToken` is deprecated. For information about refreshing OAuth access tokens, see [Renew OAuth Token](developer.squareup.com/docs/oauth-api/cookbook/renew-oauth-tokens). 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](connect.squareup.com/apps).
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/square_connect/api/o_auth_api.rb', line 92 def renew_token_with_http_info(client_id, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: OAuthApi.renew_token ..." end # verify the required parameter 'client_id' is set fail ArgumentError, "Missing the required parameter 'client_id' when calling OAuthApi.renew_token" if client_id.nil? # verify the required parameter 'body' is set fail ArgumentError, "Missing the required parameter 'body' when calling OAuthApi.renew_token" if body.nil? # resource path local_var_path = "/oauth2/clients/{client_id}/access-token/renew".sub('{format}','json').sub('{' + 'client_id' + '}', client_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-06-12" # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['oauth2ClientSecret'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'RenewTokenResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: OAuthApi#renew_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#revoke_token(body, opts = {}) ⇒ RevokeTokenResponse
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](connect.squareup.com/apps).
139 140 141 142 |
# File 'lib/square_connect/api/o_auth_api.rb', line 139 def revoke_token(body, opts = {}) data, _status_code, _headers = revoke_token_with_http_info(body, opts) return data end |
#revoke_token_with_http_info(body, opts = {}) ⇒ Array<(RevokeTokenResponse, Fixnum, Hash)>
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](connect.squareup.com/apps).
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/square_connect/api/o_auth_api.rb', line 149 def revoke_token_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: OAuthApi.revoke_token ..." end # verify the required parameter 'body' is set fail ArgumentError, "Missing the required parameter 'body' when calling OAuthApi.revoke_token" if body.nil? # resource path local_var_path = "/oauth2/revoke".sub('{format}','json') # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-06-12" # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['oauth2ClientSecret'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'RevokeTokenResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: OAuthApi#revoke_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |