Python
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
api_token = client.iam.api_tokens.get(
token_id=0,
client_id=0,
)
print(api_token.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/iam"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
apiToken, err := client.Iam.APITokens.Get(
context.TODO(),
0,
iam.APITokenGetParams{
ClientID: 0,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", apiToken.ID)
}
curl --request GET \
--url https://api.gcore.com/iam/v2/clients/{clientId}/tokens/{tokenId} \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/iam/v2/clients/{clientId}/tokens/{tokenId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/iam/v2/clients/{clientId}/tokens/{tokenId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/iam/v2/clients/{clientId}/tokens/{tokenId}")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/iam/v2/clients/{clientId}/tokens/{tokenId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"name": "My token",
"exp_date": "2021-01-01T12:00:00.000000Z",
"client_user": {
"role": {
"id": 1,
"name": "Administrators"
},
"deleted": false,
"user_id": 123,
"user_name": "John Doe",
"user_email": "some@email.com",
"client_id": 456
},
"id": 42,
"deleted": false,
"expired": false,
"created": "2021-01-01T12:00:00.000000Z",
"last_usage": "2021-01-01T12:00:00.000000Z",
"description": "It's my token"
}API Tokens
Get API token
Get information about a specific API token.
This endpoint is identical to the V1 endpoint.
GET
/
iam
/
v2
/
clients
/
{clientId}
/
tokens
/
{tokenId}
Python
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
api_token = client.iam.api_tokens.get(
token_id=0,
client_id=0,
)
print(api_token.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/iam"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
apiToken, err := client.Iam.APITokens.Get(
context.TODO(),
0,
iam.APITokenGetParams{
ClientID: 0,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", apiToken.ID)
}
curl --request GET \
--url https://api.gcore.com/iam/v2/clients/{clientId}/tokens/{tokenId} \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/iam/v2/clients/{clientId}/tokens/{tokenId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/iam/v2/clients/{clientId}/tokens/{tokenId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/iam/v2/clients/{clientId}/tokens/{tokenId}")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/iam/v2/clients/{clientId}/tokens/{tokenId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"name": "My token",
"exp_date": "2021-01-01T12:00:00.000000Z",
"client_user": {
"role": {
"id": 1,
"name": "Administrators"
},
"deleted": false,
"user_id": 123,
"user_name": "John Doe",
"user_email": "some@email.com",
"client_id": 456
},
"id": 42,
"deleted": false,
"expired": false,
"created": "2021-01-01T12:00:00.000000Z",
"last_usage": "2021-01-01T12:00:00.000000Z",
"description": "It's my token"
}Authorizations
Response
OK.
Was this page helpful?