og — 11/30/2022, 8:01:07 PM

how do I log in with a python script?

♥ 4 ↩ 0 💬 10 comments

comments

wynd:

send { username, password } to https://api.wasteof.money/session to get a token

11/30/2022, 8:04:54 PM
wynd:

in a post request

11/30/2022, 8:05:09 PM
og:

tysm

11/30/2022, 8:06:51 PM
og:

Does that mean im logged in on the script now?

11/30/2022, 8:07:53 PM
radi8:

no, you need to provide the token returned as an Authorization header in future requests

11/30/2022, 8:12:53 PM
og:

Can you give an example?

11/30/2022, 8:15:36 PM
wynd:
// js
fetch(`https://api.wasteof.money`, { headers: { Authorization: <TOKEN>}})
11/30/2022, 8:23:15 PM
wynd:

this is untested but should work:

requests.post("https://api.wasteof.money", headers={ Authorization: <TOKEN> })
11/30/2022, 8:26:40 PM
radi8:

this will make a post:

import requests

authJson = {"Authorization": "my token"}

post = requests.post("https://api.wasteof.money/posts", headers = authJson, json = {"post": "api test"})
11/30/2022, 8:28:17 PM
radi8:

or to get your token:

import requests
requests.get("https://wasteof.money/session", json={"username": "user", "password": "password"})
11/30/2022, 8:30:15 PM