Last active
December 4, 2022 15:32
-
-
Save paulwababu/2e03e58f1cdd2729072de14fa9661bf1 to your computer and use it in GitHub Desktop.
Authentication PESAPEDIA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = new RestClient("https://pesapedia.co.ke/api/v2/api-token-auth"); | |
client.Timeout = -1; | |
var request = new RestRequest(Method.POST); | |
request.AlwaysMultipartFormData = true; | |
request.AddParameter("username", "xxx"); | |
request.AddParameter("password", "xxx"); | |
IRestResponse response = client.Execute(request); | |
Console.WriteLine(response.Content); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl --location --request POST 'https://pesapedia.co.ke/api/v2/api-token-auth' \ | |
--form 'username="xxx"' \ | |
--form 'password="xxx"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = http.MultipartRequest('POST', Uri.parse('https://pesapedia.co.ke/api/v2/api-token-auth')); | |
request.fields.addAll({ | |
'username': 'xxx', | |
'password': 'xxx' | |
}); | |
http.StreamedResponse response = await request.send(); | |
if (response.statusCode == 200) { | |
print(await response.stream.bytesToString()); | |
} | |
else { | |
print(response.reasonPhrase); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"bytes" | |
"mime/multipart" | |
"net/http" | |
"io/ioutil" | |
) | |
func main() { | |
url := "https://pesapedia.co.ke/api/v2/api-token-auth" | |
method := "POST" | |
payload := &bytes.Buffer{} | |
writer := multipart.NewWriter(payload) | |
_ = writer.WriteField("username", "xxx") | |
_ = writer.WriteField("password", "xxx") | |
err := writer.Close() | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
client := &http.Client { | |
} | |
req, err := http.NewRequest(method, url, payload) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
req.Header.Set("Content-Type", writer.FormDataContentType()) | |
res, err := client.Do(req) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
defer res.Body.Close() | |
body, err := ioutil.ReadAll(res.Body) | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
fmt.Println(string(body)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var formdata = new FormData(); | |
formdata.append("username", "xxx"); | |
formdata.append("password", "xxx"); | |
var requestOptions = { | |
method: 'POST', | |
body: formdata, | |
redirect: 'follow' | |
}; | |
fetch("https://pesapedia.co.ke/api/v2/api-token-auth", requestOptions) | |
.then(response => response.text()) | |
.then(result => console.log(result)) | |
.catch(error => console.log('error', error)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var form = new FormData(); | |
form.append("username", "xxx"); | |
form.append("password", "xxx"); | |
var settings = { | |
"url": "https://pesapedia.co.ke/api/v2/api-token-auth", | |
"method": "POST", | |
"timeout": 0, | |
"processData": false, | |
"mimeType": "multipart/form-data", | |
"contentType": false, | |
"data": form | |
}; | |
$.ajax(settings).done(function (response) { | |
console.log(response); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WARNING: For POST requests, body is set to null by browsers. | |
var data = new FormData(); | |
data.append("username", "xxx"); | |
data.append("password", "xxx"); | |
var xhr = new XMLHttpRequest(); | |
xhr.withCredentials = true; | |
xhr.addEventListener("readystatechange", function() { | |
if(this.readyState === 4) { | |
console.log(this.responseText); | |
} | |
}); | |
xhr.open("POST", "https://pesapedia.co.ke/api/v2/api-token-auth"); | |
xhr.send(data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var https = require('follow-redirects').https; | |
var fs = require('fs'); | |
var options = { | |
'method': 'POST', | |
'hostname': 'pesapedia.co.ke', | |
'path': '/api/v2/api-token-auth', | |
'headers': { | |
}, | |
'maxRedirects': 20 | |
}; | |
var req = https.request(options, function (res) { | |
var chunks = []; | |
res.on("data", function (chunk) { | |
chunks.push(chunk); | |
}); | |
res.on("end", function (chunk) { | |
var body = Buffer.concat(chunks); | |
console.log(body.toString()); | |
}); | |
res.on("error", function (error) { | |
console.error(error); | |
}); | |
}); | |
var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\nxxx\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\nxxx\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"; | |
req.setHeader('content-type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'); | |
req.write(postData); | |
req.end(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var axios = require('axios'); | |
var FormData = require('form-data'); | |
var data = new FormData(); | |
data.append('username', 'xxx'); | |
data.append('password', 'xxx'); | |
var config = { | |
method: 'post', | |
url: 'https://pesapedia.co.ke/api/v2/api-token-auth', | |
headers: { | |
...data.getHeaders() | |
}, | |
data : data | |
}; | |
axios(config) | |
.then(function (response) { | |
console.log(JSON.stringify(response.data)); | |
}) | |
.catch(function (error) { | |
console.log(error); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var options = { | |
'method': 'POST', | |
'url': 'https://pesapedia.co.ke/api/v2/api-token-auth', | |
'headers': { | |
}, | |
formData: { | |
'username': 'xxx', | |
'password': 'xxx' | |
} | |
}; | |
request(options, function (error, response) { | |
if (error) throw new Error(error); | |
console.log(response.body); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var unirest = require('unirest'); | |
var req = unirest('POST', 'https://pesapedia.co.ke/api/v2/api-token-auth') | |
.field('username', 'xxx') | |
.field('password', 'xxx') | |
.end(function (res) { | |
if (res.error) throw new Error(res.error); | |
console.log(res.raw_body); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$curl = curl_init(); | |
curl_setopt_array($curl, array( | |
CURLOPT_URL => 'https://pesapedia.co.ke/api/v2/api-token-auth', | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_ENCODING => '', | |
CURLOPT_MAXREDIRS => 10, | |
CURLOPT_TIMEOUT => 0, | |
CURLOPT_FOLLOWLOCATION => true, | |
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | |
CURLOPT_CUSTOMREQUEST => 'POST', | |
CURLOPT_POSTFIELDS => array('username' => 'xxx','password' => 'xxx'), | |
)); | |
$response = curl_exec($curl); | |
curl_close($curl); | |
echo $response; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
url = "https://pesapedia.co.ke/api/v2/api-token-auth" | |
payload={'username': 'xxx', 'password': 'xxx'} | |
files=[] | |
headers = {} | |
response = requests.request("POST", url, headers=headers, data=payload, files=files) | |
print(response.text) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
body = list( | |
'username' = 'xxx', | |
'password' = 'xxx' | |
) | |
res <- VERB("POST", url = "https://pesapedia.co.ke/api/v2/api-token-auth", body = body, encode = 'multipart') | |
cat(content(res, 'text')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(RCurl) | |
params = c( | |
"username" = "xxx", | |
"password" = "xxx" | |
) | |
res <- postForm("https://pesapedia.co.ke/api/v2/api-token-auth", .params = params, .opts=list(followlocation = TRUE), style = "httppost") | |
cat(res) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "uri" | |
require "net/http" | |
url = URI("https://pesapedia.co.ke/api/v2/api-token-auth") | |
https = Net::HTTP.new(url.host, url.port) | |
https.use_ssl = true | |
request = Net::HTTP::Post.new(url) | |
form_data = [['username', 'xxx'],['password', 'xxx']] | |
request.set_form form_data, 'multipart/form-data' | |
response = https.request(request) | |
puts response.read_body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http --ignore-stdin --form --follow --timeout 3600 POST 'https://pesapedia.co.ke/api/v2/api-token-auth' \ | |
'username'='xxx' \ | |
'password'='xxx' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget --no-check-certificate --quiet \ | |
--method POST \ | |
--timeout=0 \ | |
--header '' \ | |
--body-data 'username=xxx&password=xxx' \ | |
'https://pesapedia.co.ke/api/v2/api-token-auth' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment