-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthentication.js
39 lines (35 loc) · 1.04 KB
/
authentication.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const fetch = require("node-fetch");
//first take your access_token (change samples values with your correct values)
/**
* @description authentication
* @param {object} user user information
* @example user={
grant_type: "password", // Dont change it
client_id: "YOUR_CLIENT_ID",
client_secret: "YOUR_CLIENT_SECRET",
username: "YOUR_EMAIL",
password: "YOUR_PASSWORD",
* }
* @return {string} token that use for other functions
*/
module.exports = getToken = async (user) => {
const url = "https://app.metabypass.tech/CaptchaSolver/oauth/token";
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(user),
};
console.log("Authenticating...");
const response = await fetch(url, options);
try {
const result = await response.json();
const access_token = result.access_token;
console.log("Authentication done successfuly");
return access_token;
} catch {
console.log("Invalid request");
}
};