|
1 | 1 | module Square |
2 | 2 | # OAuthApi |
3 | 3 | class OAuthApi < BaseApi |
4 | | - # `RenewToken` is deprecated. For information about refreshing OAuth access |
5 | | - # tokens, see |
6 | | - # [Migrate from Renew to Refresh OAuth |
7 | | - # Tokens](https://developer.squareup.com/docs/oauth-api/migrate-to-refresh-t |
8 | | - # okens). |
9 | | - # Renews an OAuth access token before it expires. |
10 | | - # OAuth access tokens besides your application's personal access token |
11 | | - # expire after 30 days. |
12 | | - # You can also renew expired tokens within 15 days of their expiration. |
13 | | - # You cannot renew an access token that has been expired for more than 15 |
14 | | - # days. |
15 | | - # Instead, the associated user must recomplete the OAuth flow from the |
16 | | - # beginning. |
17 | | - # __Important:__ The `Authorization` header for this endpoint must have the |
18 | | - # following format: |
19 | | - # ``` |
20 | | - # Authorization: Client APPLICATION_SECRET |
21 | | - # ``` |
22 | | - # Replace `APPLICATION_SECRET` with the application secret on the |
23 | | - # **Credentials** |
24 | | - # page in the [Developer Dashboard](https://developer.squareup.com/apps). |
25 | | - # @param [String] client_id Required parameter: Your application ID, which |
26 | | - # is available on the **OAuth** page in the [Developer |
27 | | - # Dashboard](https://developer.squareup.com/apps). |
28 | | - # @param [RenewTokenRequest] body Required parameter: An object containing |
29 | | - # the fields to POST for the request. See the corresponding object |
30 | | - # definition for field details. |
31 | | - # @param [String] authorization Required parameter: Client |
32 | | - # APPLICATION_SECRET |
33 | | - # @return [RenewTokenResponse Hash] response from the API call |
34 | | - def renew_token(client_id:, |
35 | | - body:, |
36 | | - authorization:) |
37 | | - warn 'Endpoint renew_token in OAuthApi is deprecated' |
38 | | - new_api_call_builder |
39 | | - .request(new_request_builder(HttpMethodEnum::POST, |
40 | | - '/oauth2/clients/{client_id}/access-token/renew', |
41 | | - 'default') |
42 | | - .template_param(new_parameter(client_id, key: 'client_id') |
43 | | - .should_encode(true)) |
44 | | - .header_param(new_parameter('application/json', key: 'Content-Type')) |
45 | | - .body_param(new_parameter(body)) |
46 | | - .header_param(new_parameter(authorization, key: 'Authorization')) |
47 | | - .header_param(new_parameter('application/json', key: 'accept')) |
48 | | - .body_serializer(proc do |param| param.to_json unless param.nil? end)) |
49 | | - .response(new_response_handler |
50 | | - .deserializer(APIHelper.method(:json_deserialize)) |
51 | | - .is_api_response(true) |
52 | | - .convertor(ApiResponse.method(:create))) |
53 | | - .execute |
54 | | - end |
55 | | - |
56 | 4 | # Revokes an access token generated with the OAuth flow. |
57 | 5 | # If an account has more than one OAuth access token for your application, |
58 | 6 | # this |
|
0 commit comments