rhgrant10 / berserk

Python client for the lichess API
https://berserk.readthedocs.io
Other
142 stars 36 forks source link

Oauth2 #39

Closed jhudsy closed 3 years ago

jhudsy commented 3 years ago

This is probably my own stupidity rather than an issue, but when trying to use berserk with Oauth2 authentication, I can't seem to get it working as it's unable to work with the code_challenge required for lichess. The documentation states that this is outside the scope of the project, but adding a simple example for how this should be done would be very helpful.

jhudsy commented 3 years ago

I managed to (finally) get it working. Suggested adding a simple note to the documentation that the token from Oauth2 should be passed into a TokenSession when invoking the client. e.g., client=berserk.Client(berserk.TokenSession(bearer)) where bearer is the token. If using Flask (for example), this could be obtained via

token = oauth.lichess.authorize_access_token()
bearer = token['access_token']
client=berserk.Client(berserk.TokenSession(bearer))