POST : API to Validate Access Token
POST
https://<appname>.metered.live/api/v1/token/validate
<appname>
- replace it the name of your app.
Description
This endpoint allows you to Validate a Token
Parameters
Parameters | Description | Required | Options | |
---|---|---|---|---|
Body | application/json | |||
token | string | auth token | yes | - |
Request Samples
- cURL
- NodeJs
- Ruby
- Python
- Go
cURL
curl --request POST \
--url 'https://appname.metered.live/api/v1/token/validate' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"token": "access_token"}'
NodeJs (Axios)
//We are using axios to send requests in our example
const axios = require('axios');
async function (){
try{
const response = await axios({
method: 'post',
url: 'https://appname.metered.live/api/v1/token/validate',
data: {
"token" : "access_token"
},
})
console.log(response)
} catch(error){
console.log(error)
}
}
Ruby
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://yourapp.metered.live/api/v1/token/validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
response = http.request(request)
puts response.read_body
Python
import requests
url = "https://yourapp.metered.live/api/v1/token/validate"
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
response = requests.request("POST", url, headers=headers)
print(response.text)
Go
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"strings"
)
func main() {
client := &http.Client{}
var data = strings.NewReader(`{"token": "access_token"}`)
req, err := http.NewRequest("POST", "https://appname.metered.live/api/v1/token/validate", data)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
bodyText, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}
Responses
200
{
"name": "James Bond"
}
400
{
"success": false,
"message": "Invalid request"
}