fromgithubkitimportGitHub,OAuthDeviceAuthStrategy,OAuthTokenAuthStrategy# sync/async func for displaying user code to userdefcallback(data:dict):print(data["user_code"])user_github=GitHub(OAuthDeviceAuthStrategy("<client_id>",callback))# if you want to store the user token in a databaseauth:OAuthTokenAuthStrategy=user_github.auth.exchange_token(user_github)access_token=auth.tokenrefresh_token=auth.refresh_token# restore the user token from databaseuser_github=user_github.with_auth(OAuthTokenAuthStrategy("<client_id>",None,refresh_token=refresh_token))
fromgithubkitimportGitHub,OAuthDeviceAuthStrategy,OAuthTokenAuthStrategy# sync/async func for displaying user code to userasyncdefcallback(data:dict):print(data["user_code"])user_github=GitHub(OAuthDeviceAuthStrategy("<client_id>",callback))# if you want to store the user token in a databaseauth:OAuthTokenAuthStrategy=awaituser_github.auth.async_exchange_token(user_github)access_token=auth.tokenrefresh_token=auth.refresh_token# restore the user token from databaseuser_github=user_github.with_auth(OAuthTokenAuthStrategy("<client_id>",None,refresh_token=refresh_token))