Authentication

Steps to Make a Token Request

  1. Set Up the Request:
    Prepare a POST request to the token endpoint with the required parameters:

    • client_id: Your client ID.
    • client_secret: Your client's secret.
    • grant_type: Your access type.
    • scope: The scope of access required.
  2. Send the Request:
    Make a POST request with the above parameters using an HTTP client of your choice (e.g., Postman, cURL, or within your application).

Sample Token Request

POST /oauth/token HTTP/1.1
Host: api.wapipay.com
Content-Type: application/x-www-form-urlencoded

client_id=your_client_id&client_secret=your_client_secret&grant_type=client_credentials&scope=your_scope
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        using var client = new HttpClient();
        var content = new StringContent(
            "client_id=your_client_id&client_secret=your_client_secret&grant_type=client_credentials&scope=your_scope", 
            Encoding.UTF8, 
            "application/x-www-form-urlencoded");

        var response = await client.PostAsync("https://api.wapipay.com/oauth/token", content);
        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}

package main

import (
	"bytes"
	"fmt"
	"net/http"
)

func main() {
	url := "https://api.wapipay.com/oauth/token"
	data := []byte("client_id=your_client_id&client_secret=your_client_secret&grant_type=client_credentials&scope=your_scope")
	req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
	if err != nil {
		panic(err)
	}

	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	fmt.Println("Status:", resp.Status)
}

const https = require('https');
const querystring = require('querystring');

const data = querystring.stringify({
    client_id: 'your_client_id',
    client_secret: 'your_client_secret',
    grant_type: 'client_credentials',
    scope: 'your_scope',
});

const options = {
    hostname: 'api.wapipay.com',
    path: '/oauth/token',
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': data.length,
    },
};

const req = https.request(options, (res) => {
    let response = '';
    res.on('data', (chunk) => {
        response += chunk;
    });
    res.on('end', () => {
        console.log(response);
    });
});

req.write(data);
req.end();

import requests

url = "https://api.wapipay.com/oauth/token"
data = {
    "client_id": "your_client_id",
    "client_secret": "your_client_secret",
    "grant_type": "client_credentials",
    "scope": "your_scope",
}

response = requests.post(url, data=data)
print(response.text)

import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) throws Exception {
        String url = "https://api.wapipay.com/oauth/token";
        String params = "client_id=your_client_id&client_secret=your_client_secret&grant_type=client_credentials&scope=your_scope";

        HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        connection.setDoOutput(true);

        try (OutputStream os = connection.getOutputStream()) {
            os.write(params.getBytes());
            os.flush();
        }

        int responseCode = connection.getResponseCode();
        System.out.println("Response Code: " + responseCode);
    }
}

curl -X POST https://api.wapipay.com/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=your_client_id&client_secret=your_client_secret&grant_type=client_credentials&scope=your_scope"

const fetch = require('node-fetch'); // Use in Node.js; omit for browser use

const url = "https://api.wapipay.com/oauth/token";
const headers = {
    "Content-Type": "application/x-www-form-urlencoded",
};
const body = new URLSearchParams({
    client_id: "your_client_id",
    client_secret: "your_client_secret",
    grant_type: "client_credentials",
    scope: "your_scope",
});

fetch(url, {
    method: "POST",
    headers,
    body,
})
    .then((response) => response.json())
    .then((data) => console.log(data))
    .catch((error) => console.error(error));

  1. Handle the Response:
    Upon success, the response will contain access_token, expires_in, token_type, and scope.