Send your credential's username and secret to the token endpoint. Trao đổi này không cần mã thông báo mang. Sử dụng mã thông báo truy cập được trả về làm mã thông báo mang cho các yêu cầu REST tiếp theo.
password: This JSON field carries your API credential secret, not your account login password.
Đưa ra yêu cầu đầu tiên của bạn
Chạy ví dụ cục bộ. It prompts for your credential, obtains an access token and lists the first page of devices. Giữ mã thông báo ở chế độ riêng tư. Những trang tài liệu này không bao giờ yêu cầu hoặc lưu trữ thông tin xác thực.
Choose a language and install the dependencies listed below. Các ví dụ sử dụng địa chỉ API đám mây. Never paste real secrets into documentation, support tickets or shared logs.
cURL: Bash + jq · Python: requests · C#: .NET 8+ (HttpClient)
C#: dotnet new console → Program.cs → dotnet run
$credential = Get-Credential
$body = @{
username = $credential.UserName
password = $credential.GetNetworkCredential().Password
audience = "api"
} | ConvertTo-Json
$token = Invoke-RestMethod -Method Post -Uri "https://api.remotegymp.com/v1/auth/token" -ContentType "application/json" -Body $body
$env:RG_API_TOKEN = $token.accessToken
Invoke-RestMethod -Uri "https://api.remotegymp.com/v1/devices?pageSize=25" -Headers @{ Authorization = "Bearer $env:RG_API_TOKEN" }Phản hồi mã thông báo truy cập
The credential exchange returns the fields below. Mã thông báo hiển thị ở đây là một trình giữ chỗ. The lifetime is in seconds and the expiry timestamp is UTC.
{
"accessToken": "<access-token>",
"tokenType": "Bearer",
"expiresIn": 1800,
"expiresAtUtc": "2026-10-26T12:30:00Z"
}Mã thông báo được cấp bằng chứng xác thực có thời hạn sử dụng là 30 phút. Trao đổi này không trả lại mã thông báo làm mới. Khi mã thông báo hết hạn, hãy trao đổi lại thông tin xác thực. For an interrupted write, check its outcome and the endpoint's retry rules before resubmitting it.
Chọn nơi có thể sử dụng mã thông báo truy cập
audience: "api"- Sử dụng giá trị này cho các yêu cầu API REST. It is the default when the audience field is omitted.
audience: "mcp"- Chỉ sử dụng giá trị này cho máy khách MCP được định cấu hình bằng mã thông báo mang. Thông tin xác thực phải được bật MCP. Mã thông báo API và MCP không thể được sử dụng thay thế cho nhau.
Nếu xác thực thất bại
- 401
- Check the username and secret, credential expiry and revocation. On an authenticated request, also check token expiry and audience. Repeating the same invalid credential will not fix the problem.
- 403
- Kiểm tra mã phản hồi và tin nhắn. Quyền truy cập có thể bị chặn bởi các quyền, chính sách mạng hoặc quốc gia, quyền truy cập hiện tại của Chủ sở hữu hoặc tính đủ điều kiện của tiện ích bổ sung. Mã thông báo mới không bỏ qua các bước kiểm tra đó.
- 429 ·
Retry-After - Wait for the delay given in the response header before trying again. The default token-attempt limit is 10 per source IP per minute on each Relay. Cài đặt nền tảng có thể thay đổi giới hạn này.