exchangeAccessKeyToken
Exchange access key credentials for a session token (OAuth2 client_credentials)
RFC 6749 client_credentials grant. Exchanges a client_id/client_secret pair for a short-lived session token. Credentials can be provided via HTTP Basic authentication (recommended) or as form-encoded body parameters.
/api/v1/auth/access-keys/token
Usage and SDK Samples
curl -X POST \
-H "Authorization: Basic [[basicHash]]" \
-H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
"http://localhost:8082/api/v1/auth/access-keys/token"
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
import org.openapitools.client.api.AccessKeysApi;
import java.io.File;
import java.util.*;
public class AccessKeysApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: basicAuth
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR USERNAME");
basicAuth.setPassword("YOUR PASSWORD");
// Create an instance of the API class
AccessKeysApi apiInstance = new AccessKeysApi();
String grantType = grantType_example; // String | Must be "client_credentials"
String clientId = clientId_example; // String | OAuth client ID (alternative to Basic auth header)
String clientSecret = clientSecret_example; // String | OAuth client secret (alternative to Basic auth header)
try {
AccessKeyTokenResponse result = apiInstance.exchangeAccessKeyToken(grantType, clientId, clientSecret);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AccessKeysApi#exchangeAccessKeyToken");
e.printStackTrace();
}
}
}
import 'package:openapi/api.dart';
final api_instance = DefaultApi();
final String grantType = new String(); // String | Must be "client_credentials"
final String clientId = new String(); // String | OAuth client ID (alternative to Basic auth header)
final String clientSecret = new String(); // String | OAuth client secret (alternative to Basic auth header)
try {
final result = await api_instance.exchangeAccessKeyToken(grantType, clientId, clientSecret);
print(result);
} catch (e) {
print('Exception when calling DefaultApi->exchangeAccessKeyToken: $e\n');
}
import org.openapitools.client.api.AccessKeysApi;
public class AccessKeysApiExample {
public static void main(String[] args) {
AccessKeysApi apiInstance = new AccessKeysApi();
String grantType = grantType_example; // String | Must be "client_credentials"
String clientId = clientId_example; // String | OAuth client ID (alternative to Basic auth header)
String clientSecret = clientSecret_example; // String | OAuth client secret (alternative to Basic auth header)
try {
AccessKeyTokenResponse result = apiInstance.exchangeAccessKeyToken(grantType, clientId, clientSecret);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AccessKeysApi#exchangeAccessKeyToken");
e.printStackTrace();
}
}
}
Configuration *apiConfig = [Configuration sharedConfig];
// Configure HTTP basic authorization (authentication scheme: basicAuth)
[apiConfig setUsername:@"YOUR_USERNAME"];
[apiConfig setPassword:@"YOUR_PASSWORD"];
// Create an instance of the API class
AccessKeysApi *apiInstance = [[AccessKeysApi alloc] init];
String *grantType = grantType_example; // Must be "client_credentials" (default to null)
String *clientId = clientId_example; // OAuth client ID (alternative to Basic auth header) (optional) (default to null)
String *clientSecret = clientSecret_example; // OAuth client secret (alternative to Basic auth header) (optional) (default to null)
// Exchange access key credentials for a session token (OAuth2 client_credentials)
[apiInstance exchangeAccessKeyTokenWith:grantType
clientId:clientId
clientSecret:clientSecret
completionHandler: ^(AccessKeyTokenResponse output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
var AnywhereCloudAuthApi = require('anywhere_cloud_auth_api');
var defaultClient = AnywhereCloudAuthApi.ApiClient.instance;
// Configure HTTP basic authorization: basicAuth
var basicAuth = defaultClient.authentications['basicAuth'];
basicAuth.username = 'YOUR USERNAME';
basicAuth.password = 'YOUR PASSWORD';
// Create an instance of the API class
var api = new AnywhereCloudAuthApi.AccessKeysApi()
var grantType = grantType_example; // {String} Must be "client_credentials"
var opts = {
'clientId': clientId_example, // {String} OAuth client ID (alternative to Basic auth header)
'clientSecret': clientSecret_example // {String} OAuth client secret (alternative to Basic auth header)
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.exchangeAccessKeyToken(grantType, opts, callback);
using System;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
namespace Example
{
public class exchangeAccessKeyTokenExample
{
public void main()
{
// Configure HTTP basic authorization: basicAuth
Configuration.Default.Username = "YOUR_USERNAME";
Configuration.Default.Password = "YOUR_PASSWORD";
// Create an instance of the API class
var apiInstance = new AccessKeysApi();
var grantType = grantType_example; // String | Must be "client_credentials" (default to null)
var clientId = clientId_example; // String | OAuth client ID (alternative to Basic auth header) (optional) (default to null)
var clientSecret = clientSecret_example; // String | OAuth client secret (alternative to Basic auth header) (optional) (default to null)
try {
// Exchange access key credentials for a session token (OAuth2 client_credentials)
AccessKeyTokenResponse result = apiInstance.exchangeAccessKeyToken(grantType, clientId, clientSecret);
Debug.WriteLine(result);
} catch (Exception e) {
Debug.Print("Exception when calling AccessKeysApi.exchangeAccessKeyToken: " + e.Message );
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure HTTP basic authorization: basicAuth
OpenAPITools\Client\Configuration::getDefaultConfiguration()->setUsername('YOUR_USERNAME');
OpenAPITools\Client\Configuration::getDefaultConfiguration()->setPassword('YOUR_PASSWORD');
// Create an instance of the API class
$api_instance = new OpenAPITools\Client\Api\AccessKeysApi();
$grantType = grantType_example; // String | Must be "client_credentials"
$clientId = clientId_example; // String | OAuth client ID (alternative to Basic auth header)
$clientSecret = clientSecret_example; // String | OAuth client secret (alternative to Basic auth header)
try {
$result = $api_instance->exchangeAccessKeyToken($grantType, $clientId, $clientSecret);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AccessKeysApi->exchangeAccessKeyToken: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::OPenAPIClient::Configuration;
use WWW::OPenAPIClient::AccessKeysApi;
# Configure HTTP basic authorization: basicAuth
$WWW::OPenAPIClient::Configuration::username = 'YOUR_USERNAME';
$WWW::OPenAPIClient::Configuration::password = 'YOUR_PASSWORD';
# Create an instance of the API class
my $api_instance = WWW::OPenAPIClient::AccessKeysApi->new();
my $grantType = grantType_example; # String | Must be "client_credentials"
my $clientId = clientId_example; # String | OAuth client ID (alternative to Basic auth header)
my $clientSecret = clientSecret_example; # String | OAuth client secret (alternative to Basic auth header)
eval {
my $result = $api_instance->exchangeAccessKeyToken(grantType => $grantType, clientId => $clientId, clientSecret => $clientSecret);
print Dumper($result);
};
if ($@) {
warn "Exception when calling AccessKeysApi->exchangeAccessKeyToken: $@\n";
}
from __future__ import print_statement
import time
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Configure HTTP basic authorization: basicAuth
openapi_client.configuration.username = 'YOUR_USERNAME'
openapi_client.configuration.password = 'YOUR_PASSWORD'
# Create an instance of the API class
api_instance = openapi_client.AccessKeysApi()
grantType = grantType_example # String | Must be "client_credentials" (default to null)
clientId = clientId_example # String | OAuth client ID (alternative to Basic auth header) (optional) (default to null)
clientSecret = clientSecret_example # String | OAuth client secret (alternative to Basic auth header) (optional) (default to null)
try:
# Exchange access key credentials for a session token (OAuth2 client_credentials)
api_response = api_instance.exchange_access_key_token(grantType, clientId=clientId, clientSecret=clientSecret)
pprint(api_response)
except ApiException as e:
print("Exception when calling AccessKeysApi->exchangeAccessKeyToken: %s\n" % e)
extern crate AccessKeysApi;
pub fn main() {
let grantType = grantType_example; // String
let clientId = clientId_example; // String
let clientSecret = clientSecret_example; // String
let mut context = AccessKeysApi::Context::default();
let result = client.exchangeAccessKeyToken(grantType, clientId, clientSecret, &context).wait();
println!("{:?}", result);
}
Scopes
Parameters
| Name | Description |
|---|---|
| grant_type* |
String
Must be "client_credentials"
Enum:
client_credentials
Required
|
| client_id |
String
OAuth client ID (alternative to Basic auth header)
|
| client_secret |
String
OAuth client secret (alternative to Basic auth header)
|
Responses
| Name | Type | Format | Description |
|---|---|---|---|
| WWW-Authenticate | String |