Open impuLssse opened 2 years ago
How i can form a jwt token?
const token = jwt.sign({
code: '4EKSKF'
}, 'mySecret')
axios({
url: 'https://api.surfshark.com/v3/auth/remote',
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`
}
})
.then( (res) => console.log(res.data) )
.catch( (err) => console.log(err) )
console.log(token)
There's no documentation but you should be able to figure out the important bits from my janky python code. Just check out API.py
First off, jwt isn't used.
For phone login, account/authorization/create
gives you a code and a hash. The code is for giving to the phone app, The hash used by polling auth/remote
with the json POST payload of {"hash": hash}
. It'll return a token and renewal token on success.
Using auth/login
with your username
and password
{another POSTed json payload) will log you and give you a token and renewal token also.
That token is used for the Bearer
for the api calls that need auth.
As far as I understand, to log in to the surfshark API, I need to get a token. How do I get this token?
Make a POST request for auth/login
, but where to register username and password?
Logging into the API gives you the token to use. You can log in via entering a code into an already logged in app on your phone, or by providing the username and password associated with the account you are paying Surfshark for.
I don't know There is no documentation on this, how can I connect?
In my task, it is necessary to connect, keep the connection and authorize new five-digit codes