dnplus / streamlit-oauth

Simple OAuth Component for Streamlit App
MIT License
111 stars 18 forks source link

OAuth2Component.authorize_button() Not Returning Refresh Token #5

Closed ACB-prgm closed 8 months ago

ACB-prgm commented 10 months ago

Hello,

When I call OAuth2Component.authorize_button(), It works (mostly) but I only get the access token and used auth code. It also does not close the popup window which can confuse the end user. This is using the dropbox and google drive APIs.

response: {'code': 'xxx', 'state': '0334945248', 'token': {'access_token': 'xxx', 'token_type': 'bearer', 'expires_in': 14400, 'scope': 'account_info.read files.content.read files.metadata.read', 'uid': 'xxx', 'account_id': 'xxx', 'expires_at': 1694394686}}

I know the flow returns a refresh token because I previously did this on my Flask app. Is there a reason for this? I would love it if you allowed the users a little more control over the process. I really only want the ability to handle the auth callback redirect, and Im sure other people have their own use cases.

twyangqian commented 8 months ago

I have same problem, authorize_button not return refresh token

dnplus commented 8 months ago

I noticed that they're using a non-standard parameter, "token_access_type=offline," to control the return of the refresh token. It might be a good idea to consider supporting this in the future, but it could require some changes to the httpx-oauth package or passthrough some params.

twyangqian commented 8 months ago

Hi Dylan @dnplus I modify authorize_button that adding extras_params, then can set {'token_access_type': 'offline'} param when get authorization url. And I tested the new code, it can return refresh token after click authorize_button. image

pull request url: https://github.com/dnplus/streamlit-oauth/pull/6 TKS~

twyangqian commented 8 months ago

self.oauth2.authorize_button("Continue with Google", self.redirect_uri, self.scope, key='authorize', extras_params={'access_type': 'offline'})

dnplus commented 8 months ago

Thanks @twyangqian Close with #6