authToken
Получить токен доступа
Возвращает OAuth2 токен доступа, используя grant type client_credentials. Клиент должен аутентифицироваться через Basic Authentication.
/oauth2/token
Примеры использования и SDK
curl -X POST \
-H "Authorization: Bearer [[accessToken]]" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
"http://localhost:9443/oauth2/token" \
-d ''
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
import org.openapitools.client.api.AuthenticationApi;
import java.io.File;
import java.util.*;
public class AuthenticationApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure Bearer (JWT) access token for authorization: Bearer_Authentication
HttpBearerAuth Bearer_Authentication = (HttpBearerAuth) defaultClient.getAuthentication("Bearer_Authentication");
Bearer_Authentication.setBearerToken("BEARER TOKEN");
// Create an instance of the API class
AuthenticationApi apiInstance = new AuthenticationApi();
AuthTokenRequest authTokenRequest = ; // AuthTokenRequest |
try {
authToken_200_response result = apiInstance.authToken(authTokenRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AuthenticationApi#authToken");
e.printStackTrace();
}
}
}
import 'package:openapi/api.dart';
final api_instance = DefaultApi();
final AuthTokenRequest authTokenRequest = new AuthTokenRequest(); // AuthTokenRequest |
try {
final result = await api_instance.authToken(authTokenRequest);
print(result);
} catch (e) {
print('Exception when calling DefaultApi->authToken: $e\n');
}
import org.openapitools.client.api.AuthenticationApi;
public class AuthenticationApiExample {
public static void main(String[] args) {
AuthenticationApi apiInstance = new AuthenticationApi();
AuthTokenRequest authTokenRequest = ; // AuthTokenRequest |
try {
authToken_200_response result = apiInstance.authToken(authTokenRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AuthenticationApi#authToken");
e.printStackTrace();
}
}
}
Configuration *apiConfig = [Configuration sharedConfig];
// Configure Bearer (JWT) access token for authorization: Bearer_Authentication
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];
// Create an instance of the API class
AuthenticationApi *apiInstance = [[AuthenticationApi alloc] init];
AuthTokenRequest *authTokenRequest = ; //
// Получить токен доступа
[apiInstance authTokenWith:authTokenRequest
completionHandler: ^(authToken_200_response output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
var Api = require('api_____');
var defaultClient = Api.ApiClient.instance;
// Configure Bearer (JWT) access token for authorization: Bearer_Authentication
var Bearer_Authentication = defaultClient.authentications['Bearer_Authentication'];
Bearer_Authentication.accessToken = "YOUR ACCESS TOKEN";
// Create an instance of the API class
var api = new Api.AuthenticationApi()
var authTokenRequest = ; // {AuthTokenRequest}
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.authToken(authTokenRequest, callback);
using System;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
namespace Example
{
public class authTokenExample
{
public void main()
{
// Configure Bearer (JWT) access token for authorization: Bearer_Authentication
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
// Create an instance of the API class
var apiInstance = new AuthenticationApi();
var authTokenRequest = new AuthTokenRequest(); // AuthTokenRequest |
try {
// Получить токен доступа
authToken_200_response result = apiInstance.authToken(authTokenRequest);
Debug.WriteLine(result);
} catch (Exception e) {
Debug.Print("Exception when calling AuthenticationApi.authToken: " + e.Message );
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Bearer (JWT) access token for authorization: Bearer_Authentication
OpenAPITools\Client\Configuration::getDefaultConfiguration()->setAccessToken('', 'YOUR_ACCESS_TOKEN');
// Create an instance of the API class
$api_instance = new OpenAPITools\Client\Api\AuthenticationApi();
$authTokenRequest = ; // AuthTokenRequest |
try {
$result = $api_instance->authToken($authTokenRequest);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AuthenticationApi->authToken: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::OPenAPIClient::Configuration;
use WWW::OPenAPIClient::AuthenticationApi;
# Configure Bearer (JWT) access token for authorization: Bearer_Authentication
$WWW::OPenAPIClient::Configuration::access_token = 'YOUR_ACCESS_TOKEN';
# Create an instance of the API class
my $api_instance = WWW::OPenAPIClient::AuthenticationApi->new();
my $authTokenRequest = WWW::OPenAPIClient::Object::AuthTokenRequest->new(); # AuthTokenRequest |
eval {
my $result = $api_instance->authToken(authTokenRequest => $authTokenRequest);
print Dumper($result);
};
if ($@) {
warn "Exception when calling AuthenticationApi->authToken: $@\n";
}
from __future__ import print_statement
import time
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Configure Bearer (JWT) access token for authorization: Bearer_Authentication
openapi_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Create an instance of the API class
api_instance = openapi_client.AuthenticationApi()
authTokenRequest = # AuthTokenRequest |
try:
# Получить токен доступа
api_response = api_instance.auth_token(authTokenRequest)
pprint(api_response)
except ApiException as e:
print("Exception when calling AuthenticationApi->authToken: %s\n" % e)
extern crate AuthenticationApi;
pub fn main() {
let authTokenRequest = ; // AuthTokenRequest
let mut context = AuthenticationApi::Context::default();
let result = client.authToken(authTokenRequest, &context).wait();
println!("{:?}", result);
}
Области доступа
Параметры
Название | Описание |
---|---|
authTokenRequest * |