Obtain access token
Získa access token cez OAuth 2.0 client_credentials.
curl -X POST "https://einvoice-v1-ynyiur6quq-ey.a.run.app/v1/sapi/auth/token" \
-H "Content-Type: application/json" \
-d '{
"client_id": "example_string",
"client_secret": "example_string",
"grant_type": "client_credentials",
"scope": "document:send document:receive"
}'
import requests
import json
url = "https://einvoice-v1-ynyiur6quq-ey.a.run.app/v1/sapi/auth/token"
headers = {
"Content-Type": "application/json"
}
data = {
"client_id": "example_string",
"client_secret": "example_string",
"grant_type": "client_credentials",
"scope": "document:send document:receive"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://einvoice-v1-ynyiur6quq-ey.a.run.app/v1/sapi/auth/token", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
"client_id": "example_string",
"client_secret": "example_string",
"grant_type": "client_credentials",
"scope": "document:send document:receive"
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"client_id": "example_string",
"client_secret": "example_string",
"grant_type": "client_credentials",
"scope": "document:send document:receive"
}`)
req, err := http.NewRequest("POST", "https://einvoice-v1-ynyiur6quq-ey.a.run.app/v1/sapi/auth/token", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://einvoice-v1-ynyiur6quq-ey.a.run.app/v1/sapi/auth/token')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request.body = '{
"client_id": "example_string",
"client_secret": "example_string",
"grant_type": "client_credentials",
"scope": "document:send document:receive"
}'
response = http.request(request)
puts response.body
{
"access_token": "example_string",
"token_type": "Bearer",
"expires_in": 900,
"scope": "example_string",
"refresh_token": "example_string"
}
{
"error": "Bad Request",
"message": "The request contains invalid parameters or malformed data",
"code": 400,
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
{
"error": "Unauthorized",
"message": "Authentication required. Please provide a valid API token",
"code": 401
}
{
"error": "Forbidden",
"message": "You don't have permission to access this resource",
"code": 403
}
{
"error": "Error",
"message": "Klient je dočasne zablokovaný.",
"code": 423
}
POST
/v1/sapi/auth/token
POST
Base URLstring
Target server for requests. Edit to use your own host.
Content-Typestring
RequiredThe media type of the request body
Options: application/json
client_secretstring
RequiredFormat: password
grant_typestring
RequiredOptions: client_credentials
Request Preview
Response
Response will appear here after sending the request
Body
application/json
grant_typestring
RequiredAllowed values:
client_credentialsscopestring
Example:
document:send document:receiveResponses
access_tokenstring
token_typestring
Allowed values:
Bearerexpires_ininteger
Životnosť tokenu v sekundách.
scopestring
refresh_tokenstring
Voliteľné, iba ak je obnova podporovaná.
Was this page helpful?