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
)
user_me = client.iam.users.get_me()
print(user_me.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
userMe, err := client.Iam.Users.GetMe(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", userMe.ID)
}
curl --request GET \
--url https://api.gcore.com/iam/v2/users/me \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/iam/v2/users/me', 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/users/me",
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/users/me")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/iam/v2/users/me")
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{
"id": 123,
"email": "jsmith@example.com",
"name": "<string>",
"client": 123,
"groups": [
{
"id": 123,
"name": "<string>"
}
],
"activated": true,
"user_type": "<string>",
"two_fa": true,
"auth_types": [
"<string>"
],
"created_at": "2023-11-07T05:31:56Z",
"clients_and_roles": [
{
"client_id": 123,
"client_company_name": "<string>",
"user_roles": [
"<string>"
],
"user_id": 123,
"auth_types": [
"<string>"
]
}
],
"show_chat": true,
"can_disable_2fa": true,
"lang": "az",
"phone": "<string>"
}Users
Get current user
The authenticated user’s own profile, including the clients they belong to.
GET
/
iam
/
v2
/
users
/
me
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
)
user_me = client.iam.users.get_me()
print(user_me.id)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
userMe, err := client.Iam.Users.GetMe(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", userMe.ID)
}
curl --request GET \
--url https://api.gcore.com/iam/v2/users/me \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/iam/v2/users/me', 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/users/me",
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/users/me")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/iam/v2/users/me")
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{
"id": 123,
"email": "jsmith@example.com",
"name": "<string>",
"client": 123,
"groups": [
{
"id": 123,
"name": "<string>"
}
],
"activated": true,
"user_type": "<string>",
"two_fa": true,
"auth_types": [
"<string>"
],
"created_at": "2023-11-07T05:31:56Z",
"clients_and_roles": [
{
"client_id": 123,
"client_company_name": "<string>",
"user_roles": [
"<string>"
],
"user_id": 123,
"auth_types": [
"<string>"
]
}
],
"show_chat": true,
"can_disable_2fa": true,
"lang": "az",
"phone": "<string>"
}Authorizations
Response
OK.
The client-tier caller's own profile, including the clients they belong to.
Was this page helpful?