-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbyte.js
More file actions
49 lines (43 loc) · 1.16 KB
/
byte.js
File metadata and controls
49 lines (43 loc) · 1.16 KB
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
40
41
42
43
44
45
46
47
48
49
const axios = require('axios');
const queryString = require('querystring');
const { client_id } = require('./config');
const byteClient = axios.create({
baseURL: 'https://api.byte.co',
headers: {
'User-Agent': 'byte/0.2 (co.byte.video; build:145; iOS 12.4.0) Alamofire/4.9.1',
'Accept-Language': 'en-GB;q=1.0',
}
})
const requestGoogleToken = (code, verifier) => axios({
url: 'https://oauth2.googleapis.com/token',
method: 'POST',
headers: {
'user-agent': 'gtm-oauth2 co.byte.video/0.2',
'content-type': 'application/x-www-form-urlencoded',
},
data: queryString.stringify({
client_id,
code,
grant_type: 'authorization_code',
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
verifier,
})
});
const authenticate = (authToken) => byteClient.post('/authenticate/google', {
token: authToken
});
const checkUsername = (username) => byteClient.post('/account/register/precheck', {
username
});
const signUp = (authToken, username) => byteClient.post('/account/register', {
inviteCode: 'NA',
service: 'google',
token: authToken,
username
})
module.exports = {
requestGoogleToken,
authenticate,
checkUsername,
signUp
};