# OAuth Token Generate POST https://app.hellosign.com/oauth/token Content-Type: application/json Once you have retrieved the code from the user callback, you will need to exchange it for an access token via a backend call. Reference: https://developer.hellosign.com/docs/guides/o-auth/token-generate ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: OAuth Token Generate version: endpoint_oauth.tokenGenerate paths: /oauth/token: post: operationId: token-generate summary: OAuth Token Generate description: >- Once you have retrieved the code from the user callback, you will need to exchange it for an access token via a backend call. 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/OAuthTokenGenerateRequest' components: schemas: OAuthTokenGenerateRequest: type: object properties: client_id: type: string description: The client id of the app requesting authorization. client_secret: type: string description: The secret token of your app. code: type: string description: The code passed to your callback when the user granted access. grant_type: type: string default: authorization_code description: When generating a new token use `authorization_code`. state: type: string description: Same as the state you specified earlier. required: - client_id - client_secret - code - grant_type - state 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 setClientId("cc91c61d00f8bb2ece1428035716b") ->setClientSecret("1d14434088507ffa390e6f5528465") ->setCode("1b0d28d90c86c141") ->setState("900e06e2") ->setGrantType("authorization_code"); try { $response = (new Dropbox\Sign\Api\OAuthApi(config: $config))->oauthTokenGenerate( o_auth_token_generate_request: $o_auth_token_generate_request, ); print_r($response); } catch (Dropbox\Sign\ApiException $e) { echo "Exception when calling OAuthApi#oauthTokenGenerate: {$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 OauthTokenGenerateExample { public static void Run() { var config = new Configuration(); var oAuthTokenGenerateRequest = new OAuthTokenGenerateRequest( clientId: "cc91c61d00f8bb2ece1428035716b", clientSecret: "1d14434088507ffa390e6f5528465", code: "1b0d28d90c86c141", state: "900e06e2", grantType: "authorization_code" ); try { var response = new OAuthApi(config).OauthTokenGenerate( oAuthTokenGenerateRequest: oAuthTokenGenerateRequest ); Console.WriteLine(response); } catch (ApiException e) { Console.WriteLine("Exception when calling OAuthApi#OauthTokenGenerate: " + 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 oAuthTokenGenerateRequest: models.OAuthTokenGenerateRequest = { clientId: "cc91c61d00f8bb2ece1428035716b", clientSecret: "1d14434088507ffa390e6f5528465", code: "1b0d28d90c86c141", state: "900e06e2", grantType: "authorization_code", }; apiCaller.oauthTokenGenerate( oAuthTokenGenerateRequest, ).then(response => { console.log(response.body); }).catch(error => { console.log("Exception when calling OAuthApi#oauthTokenGenerate:"); 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 OauthTokenGenerateExample { public static void main(String[] args) { var config = Configuration.getDefaultApiClient(); var oAuthTokenGenerateRequest = new OAuthTokenGenerateRequest(); oAuthTokenGenerateRequest.clientId("cc91c61d00f8bb2ece1428035716b"); oAuthTokenGenerateRequest.clientSecret("1d14434088507ffa390e6f5528465"); oAuthTokenGenerateRequest.code("1b0d28d90c86c141"); oAuthTokenGenerateRequest.state("900e06e2"); oAuthTokenGenerateRequest.grantType("authorization_code"); try { var response = new OAuthApi(config).oauthTokenGenerate( oAuthTokenGenerateRequest ); System.out.println(response); } catch (ApiException e) { System.err.println("Exception when calling OAuthApi#oauthTokenGenerate"); 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_generate_request = Dropbox::Sign::OAuthTokenGenerateRequest.new o_auth_token_generate_request.client_id = "cc91c61d00f8bb2ece1428035716b" o_auth_token_generate_request.client_secret = "1d14434088507ffa390e6f5528465" o_auth_token_generate_request.code = "1b0d28d90c86c141" o_auth_token_generate_request.state = "900e06e2" o_auth_token_generate_request.grant_type = "authorization_code" begin response = Dropbox::Sign::OAuthApi.new.oauth_token_generate( o_auth_token_generate_request, ) p response rescue Dropbox::Sign::ApiError => e puts "Exception when calling OAuthApi#oauth_token_generate: #{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_generate_request = models.OAuthTokenGenerateRequest( client_id="cc91c61d00f8bb2ece1428035716b", client_secret="1d14434088507ffa390e6f5528465", code="1b0d28d90c86c141", state="900e06e2", grant_type="authorization_code", ) try: response = api.OAuthApi(api_client).oauth_token_generate( o_auth_token_generate_request=o_auth_token_generate_request, ) pprint(response) except ApiException as e: print("Exception when calling OAuthApi#oauth_token_generate: %s\n" % e) ``` ```go Retrieving the OAuth token package main import ( "fmt" "net/http" "io" ) func main() { url := "https://app.hellosign.com/oauth/token" 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 Retrieving the OAuth token import Foundation let headers = [ "Authorization": "Basic :", "Content-Type": "application/json" ] let request = NSMutableURLRequest(url: NSURL(string: "https://app.hellosign.com/oauth/token")! 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 setClientId("cc91c61d00f8bb2ece1428035716b") ->setClientSecret("1d14434088507ffa390e6f5528465") ->setCode("1b0d28d90c86c141") ->setState("900e06e2") ->setGrantType("authorization_code"); try { $response = (new Dropbox\Sign\Api\OAuthApi(config: $config))->oauthTokenGenerate( o_auth_token_generate_request: $o_auth_token_generate_request, ); print_r($response); } catch (Dropbox\Sign\ApiException $e) { echo "Exception when calling OAuthApi#oauthTokenGenerate: {$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 OauthTokenGenerateExample { public static void Run() { var config = new Configuration(); var oAuthTokenGenerateRequest = new OAuthTokenGenerateRequest( clientId: "cc91c61d00f8bb2ece1428035716b", clientSecret: "1d14434088507ffa390e6f5528465", code: "1b0d28d90c86c141", state: "900e06e2", grantType: "authorization_code" ); try { var response = new OAuthApi(config).OauthTokenGenerate( oAuthTokenGenerateRequest: oAuthTokenGenerateRequest ); Console.WriteLine(response); } catch (ApiException e) { Console.WriteLine("Exception when calling OAuthApi#OauthTokenGenerate: " + 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 oAuthTokenGenerateRequest: models.OAuthTokenGenerateRequest = { clientId: "cc91c61d00f8bb2ece1428035716b", clientSecret: "1d14434088507ffa390e6f5528465", code: "1b0d28d90c86c141", state: "900e06e2", grantType: "authorization_code", }; apiCaller.oauthTokenGenerate( oAuthTokenGenerateRequest, ).then(response => { console.log(response.body); }).catch(error => { console.log("Exception when calling OAuthApi#oauthTokenGenerate:"); 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 OauthTokenGenerateExample { public static void main(String[] args) { var config = Configuration.getDefaultApiClient(); var oAuthTokenGenerateRequest = new OAuthTokenGenerateRequest(); oAuthTokenGenerateRequest.clientId("cc91c61d00f8bb2ece1428035716b"); oAuthTokenGenerateRequest.clientSecret("1d14434088507ffa390e6f5528465"); oAuthTokenGenerateRequest.code("1b0d28d90c86c141"); oAuthTokenGenerateRequest.state("900e06e2"); oAuthTokenGenerateRequest.grantType("authorization_code"); try { var response = new OAuthApi(config).oauthTokenGenerate( oAuthTokenGenerateRequest ); System.out.println(response); } catch (ApiException e) { System.err.println("Exception when calling OAuthApi#oauthTokenGenerate"); 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_generate_request = Dropbox::Sign::OAuthTokenGenerateRequest.new o_auth_token_generate_request.client_id = "cc91c61d00f8bb2ece1428035716b" o_auth_token_generate_request.client_secret = "1d14434088507ffa390e6f5528465" o_auth_token_generate_request.code = "1b0d28d90c86c141" o_auth_token_generate_request.state = "900e06e2" o_auth_token_generate_request.grant_type = "authorization_code" begin response = Dropbox::Sign::OAuthApi.new.oauth_token_generate( o_auth_token_generate_request, ) p response rescue Dropbox::Sign::ApiError => e puts "Exception when calling OAuthApi#oauth_token_generate: #{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_generate_request = models.OAuthTokenGenerateRequest( client_id="cc91c61d00f8bb2ece1428035716b", client_secret="1d14434088507ffa390e6f5528465", code="1b0d28d90c86c141", state="900e06e2", grant_type="authorization_code", ) try: response = api.OAuthApi(api_client).oauth_token_generate( o_auth_token_generate_request=o_auth_token_generate_request, ) pprint(response) except ApiException as e: print("Exception when calling OAuthApi#oauth_token_generate: %s\n" % e) ``` ```go OAuth Token Generate Example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://app.hellosign.com/oauth/token" payload := strings.NewReader("{\n \"client_id\": \"cc91c61d00f8bb2ece1428035716b\",\n \"client_secret\": \"1d14434088507ffa390e6f5528465\",\n \"code\": \"1b0d28d90c86c141\",\n \"grant_type\": \"authorization_code\",\n \"state\": \"900e06e2\"\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 Generate Example import Foundation let headers = [ "Authorization": "Basic :", "Content-Type": "application/json" ] let parameters = [ "client_id": "cc91c61d00f8bb2ece1428035716b", "client_secret": "1d14434088507ffa390e6f5528465", "code": "1b0d28d90c86c141", "grant_type": "authorization_code", "state": "900e06e2" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://app.hellosign.com/oauth/token")! 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() ```