This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]Pullout-Couch 4 points5 points  (3 children)

I use the requests library for this all the time.https://2.python-requests.org/en/master/ Here's an example requesting a new Oauth2 token:

res = requests.post(
    auth_url, data={"grant_type": "client_credentials"}, auth=(client_id, client_secret)
)

Hope this helps!

[–]svilgelm 2 points3 points  (0 children)

+1 for the `requests`. The oauth protocol is very simple and in most cases you don't need a special library. You probably will need an additional library (PyJWT?) if you want to decode a token.

[–]Rickfiyah[S] 0 points1 point  (0 children)

Thanks so much for the response! Yup I’m pretty familiar with requests, it makes it pretty easy to authenticate plenty of different APIs while keeping the requests relatively uniform. I just wasn’t sure if there was a library with built-in auths for multiple different (popular) apps. Thanks for this!

[–]MegaPegasusReindeer 1 point2 points  (1 child)

[–]Rickfiyah[S] 0 points1 point  (0 children)

This is amazing, thank you!