# OAuth Token Refresh POST https://app.hellosign.com/oauth/token?refresh Content-Type: application/json Access tokens are only valid for a given period of time (typically one hour) for security reasons. Whenever acquiring an new access token its TTL is also given (see `expires_in`), along with a refresh token that can be used to acquire a new access token after the current one has expired. Reference: https://developer.hellosign.com/docs/guides/o-auth/token-refresh ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: OAuth Token Refresh version: endpoint_oauth.tokenRefresh paths: /oauth/token?refresh: post: operationId: token-refresh summary: OAuth Token Refresh description: >- Access tokens are only valid for a given period of time (typically one hour) for security reasons. Whenever acquiring an new access token its TTL is also given (see `expires_in`), along with a refresh token that can be used to acquire a new access token after the current one has expired. tags: - - subpackage_oauth parameters: - name: Authorization in: header description: Basic authentication of the form `Basic `. required: true schema: type: string responses: '200': description: successful operation content: application/json: schema: $ref: '#/components/schemas/OAuthTokenResponse' '400': description: failed_operation content: {} requestBody: content: application/json: schema: $ref: '#/components/schemas/OAuthTokenRefreshRequest' components: schemas: OAuthTokenRefreshRequest: type: object properties: grant_type: type: string default: refresh_token description: When refreshing an existing token use `refresh_token`. refresh_token: type: string description: The token provided when you got the expired access token. client_id: type: string description: >- The client ID for your API app. Required for new API apps. To enhance security, we recommend making it required for existing apps in your app settings. client_secret: type: string description: >- The client secret for your API app. Required for new API apps. To enhance security, we recommend making it required for existing apps in your app settings. required: - grant_type - refresh_token OAuthTokenResponse: type: object properties: access_token: type: string token_type: type: string refresh_token: type: string expires_in: type: integer description: Number of seconds until the `access_token` expires. Uses epoch time. state: type: - string - 'null' ``` ## SDK Code Examples ```php PHP setGrantType("refresh_token") ->setRefreshToken("hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3"); try { $response = (new Dropbox\Sign\Api\OAuthApi(config: $config))->oauthTokenRefresh( o_auth_token_refresh_request: $o_auth_token_refresh_request, ); print_r($response); } catch (Dropbox\Sign\ApiException $e) { echo "Exception when calling OAuthApi#oauthTokenRefresh: {$e->getMessage()}"; } ``` ```csharp C# using System; using System.Collections.Generic; using System.IO; using System.Text.Json; using Dropbox.Sign.Api; using Dropbox.Sign.Client; using Dropbox.Sign.Model; namespace Dropbox.SignSandbox; public class OauthTokenRefreshExample { public static void Run() { var config = new Configuration(); var oAuthTokenRefreshRequest = new OAuthTokenRefreshRequest( grantType: "refresh_token", refreshToken: "hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3" ); try { var response = new OAuthApi(config).OauthTokenRefresh( oAuthTokenRefreshRequest: oAuthTokenRefreshRequest ); Console.WriteLine(response); } catch (ApiException e) { Console.WriteLine("Exception when calling OAuthApi#OauthTokenRefresh: " + e.Message); Console.WriteLine("Status Code: " + e.ErrorCode); Console.WriteLine(e.StackTrace); } } } ``` ```typescript TypeScript import * as fs from 'fs'; import api from "@dropbox/sign" import models from "@dropbox/sign" const apiCaller = new api.OAuthApi(); const oAuthTokenRefreshRequest: models.OAuthTokenRefreshRequest = { grantType: "refresh_token", refreshToken: "hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3", }; apiCaller.oauthTokenRefresh( oAuthTokenRefreshRequest, ).then(response => { console.log(response.body); }).catch(error => { console.log("Exception when calling OAuthApi#oauthTokenRefresh:"); console.log(error.body); }); ``` ```java Java package com.dropbox.sign_sandbox; import com.dropbox.sign.ApiException; import com.dropbox.sign.Configuration; import com.dropbox.sign.api.*; import com.dropbox.sign.auth.*; import com.dropbox.sign.JSON; import com.dropbox.sign.model.*; import java.io.File; import java.math.BigDecimal; import java.time.LocalDate; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; import java.util.Map; public class OauthTokenRefreshExample { public static void main(String[] args) { var config = Configuration.getDefaultApiClient(); var oAuthTokenRefreshRequest = new OAuthTokenRefreshRequest(); oAuthTokenRefreshRequest.grantType("refresh_token"); oAuthTokenRefreshRequest.refreshToken("hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3"); try { var response = new OAuthApi(config).oauthTokenRefresh( oAuthTokenRefreshRequest ); System.out.println(response); } catch (ApiException e) { System.err.println("Exception when calling OAuthApi#oauthTokenRefresh"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` ```ruby Ruby require "json" require "dropbox-sign" Dropbox::Sign.configure do |config| end o_auth_token_refresh_request = Dropbox::Sign::OAuthTokenRefreshRequest.new o_auth_token_refresh_request.grant_type = "refresh_token" o_auth_token_refresh_request.refresh_token = "hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3" begin response = Dropbox::Sign::OAuthApi.new.oauth_token_refresh( o_auth_token_refresh_request, ) p response rescue Dropbox::Sign::ApiError => e puts "Exception when calling OAuthApi#oauth_token_refresh: #{e}" end ``` ```python Python import json from datetime import date, datetime from pprint import pprint from dropbox_sign import ApiClient, ApiException, Configuration, api, models configuration = Configuration( ) with ApiClient(configuration) as api_client: o_auth_token_refresh_request = models.OAuthTokenRefreshRequest( grant_type="refresh_token", refresh_token="hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3", ) try: response = api.OAuthApi(api_client).oauth_token_refresh( o_auth_token_refresh_request=o_auth_token_refresh_request, ) pprint(response) except ApiException as e: print("Exception when calling OAuthApi#oauth_token_refresh: %s\n" % e) ``` ```go Refresh an existing OAuth token package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.hellosign.com/oauth/token?refresh=" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Authorization", "Basic :") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```swift Refresh an existing OAuth token import Foundation let headers = [ "Authorization": "Basic :", "Content-Type": "application/json" ] let request = NSMutableURLRequest(url: NSURL(string: "https://app.hellosign.com/oauth/token?refresh=")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ```php PHP setGrantType("refresh_token") ->setRefreshToken("hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3"); try { $response = (new Dropbox\Sign\Api\OAuthApi(config: $config))->oauthTokenRefresh( o_auth_token_refresh_request: $o_auth_token_refresh_request, ); print_r($response); } catch (Dropbox\Sign\ApiException $e) { echo "Exception when calling OAuthApi#oauthTokenRefresh: {$e->getMessage()}"; } ``` ```csharp C# using System; using System.Collections.Generic; using System.IO; using System.Text.Json; using Dropbox.Sign.Api; using Dropbox.Sign.Client; using Dropbox.Sign.Model; namespace Dropbox.SignSandbox; public class OauthTokenRefreshExample { public static void Run() { var config = new Configuration(); var oAuthTokenRefreshRequest = new OAuthTokenRefreshRequest( grantType: "refresh_token", refreshToken: "hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3" ); try { var response = new OAuthApi(config).OauthTokenRefresh( oAuthTokenRefreshRequest: oAuthTokenRefreshRequest ); Console.WriteLine(response); } catch (ApiException e) { Console.WriteLine("Exception when calling OAuthApi#OauthTokenRefresh: " + e.Message); Console.WriteLine("Status Code: " + e.ErrorCode); Console.WriteLine(e.StackTrace); } } } ``` ```typescript TypeScript import * as fs from 'fs'; import api from "@dropbox/sign" import models from "@dropbox/sign" const apiCaller = new api.OAuthApi(); const oAuthTokenRefreshRequest: models.OAuthTokenRefreshRequest = { grantType: "refresh_token", refreshToken: "hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3", }; apiCaller.oauthTokenRefresh( oAuthTokenRefreshRequest, ).then(response => { console.log(response.body); }).catch(error => { console.log("Exception when calling OAuthApi#oauthTokenRefresh:"); console.log(error.body); }); ``` ```java Java package com.dropbox.sign_sandbox; import com.dropbox.sign.ApiException; import com.dropbox.sign.Configuration; import com.dropbox.sign.api.*; import com.dropbox.sign.auth.*; import com.dropbox.sign.JSON; import com.dropbox.sign.model.*; import java.io.File; import java.math.BigDecimal; import java.time.LocalDate; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.List; import java.util.Map; public class OauthTokenRefreshExample { public static void main(String[] args) { var config = Configuration.getDefaultApiClient(); var oAuthTokenRefreshRequest = new OAuthTokenRefreshRequest(); oAuthTokenRefreshRequest.grantType("refresh_token"); oAuthTokenRefreshRequest.refreshToken("hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3"); try { var response = new OAuthApi(config).oauthTokenRefresh( oAuthTokenRefreshRequest ); System.out.println(response); } catch (ApiException e) { System.err.println("Exception when calling OAuthApi#oauthTokenRefresh"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); e.printStackTrace(); } } } ``` ```ruby Ruby require "json" require "dropbox-sign" Dropbox::Sign.configure do |config| end o_auth_token_refresh_request = Dropbox::Sign::OAuthTokenRefreshRequest.new o_auth_token_refresh_request.grant_type = "refresh_token" o_auth_token_refresh_request.refresh_token = "hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3" begin response = Dropbox::Sign::OAuthApi.new.oauth_token_refresh( o_auth_token_refresh_request, ) p response rescue Dropbox::Sign::ApiError => e puts "Exception when calling OAuthApi#oauth_token_refresh: #{e}" end ``` ```python Python import json from datetime import date, datetime from pprint import pprint from dropbox_sign import ApiClient, ApiException, Configuration, api, models configuration = Configuration( ) with ApiClient(configuration) as api_client: o_auth_token_refresh_request = models.OAuthTokenRefreshRequest( grant_type="refresh_token", refresh_token="hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3", ) try: response = api.OAuthApi(api_client).oauth_token_refresh( o_auth_token_refresh_request=o_auth_token_refresh_request, ) pprint(response) except ApiException as e: print("Exception when calling OAuthApi#oauth_token_refresh: %s\n" % e) ``` ```go OAuth Token Refresh Example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.hellosign.com/oauth/token?refresh=" payload := strings.NewReader("{\n \"grant_type\": \"refresh_token\",\n \"refresh_token\": \"hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Basic :") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```swift OAuth Token Refresh Example import Foundation let headers = [ "Authorization": "Basic :", "Content-Type": "application/json" ] let parameters = [ "grant_type": "refresh_token", "refresh_token": "hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://app.hellosign.com/oauth/token?refresh=")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```