POST Authentication
Each API request is authenticated by a webpushrKey
& webpushrAuthToken
in the request header. This Key & Token is site specific and you can get this from Integration > API Keys menu in your Webpushr Web Console.
Example Request
curl -X POST \
-H "webpushrKey: <YOUR REST API KEY>" \
-H "webpushrAuthToken: <YOUR AUTHENTICATION TOKEN>" \
-H "Content-Type: application/json" \
https://api.webpushr.com/v1/authentication
$end_point = 'https://api.webpushr.com/v1/authentication';
$http_header = array(
"Content-Type: Application/Json",
"webpushrKey: <YOUR REST API KEY>",
"webpushrAuthToken: <YOUR AUTHENTICATION TOKEN>"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header);
curl_setopt($ch, CURLOPT_URL, $end_point );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo $response;
import requests
headers = {
'webpushrKey': '<YOUR REST API KEY>',
'webpushrAuthToken': '<YOUR AUTHENTICATION TOKEN>',
'Content-Type': 'application/json',
}
response = requests.post('https://api.webpushr.com/v1/authentication', headers=headers)
var request = require('request');
var headers = {
'webpushrKey': '<YOUR REST API KEY>',
'webpushrAuthToken': '<YOUR AUTHENTICATION TOKEN>',
'Content-Type': 'application/json'
};
var options = {
url: 'https://api.webpushr.com/v1/authentication',
method: 'POST',
headers: headers
};
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
}
request(options, callback);
extern crate reqwest;
use reqwest::header;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut headers = header::HeaderMap::new();
headers.insert("webpushrKey", "<YOUR REST API KEY>".parse().unwrap());
headers.insert("webpushrAuthToken", "<YOUR AUTHENTICATION TOKEN>".parse().unwrap());
headers.insert("Content-Type", "application/json".parse().unwrap());
let res = reqwest::Client::new()
.post("https://api.webpushr.com/v1/authentication")
.headers(headers)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
client := &http.Client{}
req, err := http.NewRequest("POST", "https://api.webpushr.com/v1/authentication", nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("webpushrKey", "<YOUR REST API KEY>")
req.Header.Set("webpushrAuthToken", "<YOUR AUTHENTICATION TOKEN>")
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
bodyText, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}
Result Format
{
"status" : "success",
"description" : "You are authorized",
}
{
"status": "failure",
"type" : "header_invalid",
"description": "Missing webpushrKey in header"
}
{
"status": "failure",
"type" : "authentication_failure",
"description": "You are not authorized"
}
- Got any questions? Ask the Webpushr Forum New