{"id":15501687,"url":"https://github.com/dnplus/streamlit-oauth","last_synced_at":"2025-05-15T11:06:04.128Z","repository":{"id":148759185,"uuid":"620424133","full_name":"dnplus/streamlit-oauth","owner":"dnplus","description":"Simple OAuth Component for Streamlit App","archived":false,"fork":false,"pushed_at":"2025-03-26T06:53:28.000Z","size":334,"stargazers_count":200,"open_issues_count":8,"forks_count":32,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-21T18:52:20.882Z","etag":null,"topics":["oauth2","streamlit","streamlit-component"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dnplus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["dnplus"],"polar":"dnplus","patreon":"dnplus","open_collective":null,"ko_fi":"dnplus","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-03-28T16:48:45.000Z","updated_at":"2025-04-16T15:26:26.000Z","dependencies_parsed_at":"2023-11-28T07:27:23.504Z","dependency_job_id":"ea607d4a-fc21-42e6-9cda-07d58defa289","html_url":"https://github.com/dnplus/streamlit-oauth","commit_stats":{"total_commits":70,"total_committers":10,"mean_commits":7.0,"dds":0.4571428571428572,"last_synced_commit":"8bfa73db99120d90ca481419253dfd305db79f15"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnplus%2Fstreamlit-oauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnplus%2Fstreamlit-oauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnplus%2Fstreamlit-oauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnplus%2Fstreamlit-oauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnplus","download_url":"https://codeload.github.com/dnplus/streamlit-oauth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328385,"owners_count":22052632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["oauth2","streamlit","streamlit-component"],"created_at":"2024-10-02T09:05:20.220Z","updated_at":"2025-05-15T11:06:04.065Z","avatar_url":"https://github.com/dnplus.png","language":"Python","funding_links":["https://github.com/sponsors/dnplus","https://polar.sh/dnplus","https://patreon.com/dnplus","https://ko-fi.com/dnplus"],"categories":[],"sub_categories":[],"readme":"# 🔐 Streamlit OAuth: Enhance Your Data Apps with Seamless Integration\n[![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://g-openid-demo.streamlit.app/)\n\n**Effortlessly integrate OAuth2 authorization into your Streamlit apps using the streamlined httpx_oauth wrapper**\n\n## Why Streamlit OAuth?\n\nIn today's digital landscape, authorization is crucial for accessing and utilizing data from various applications. With Streamlit OAuth, you can easily incorporate OAuth2 authorization into your Streamlit data apps, allowing you to securely and efficiently fetch data from other applications. This powerful integration unlocks the full potential of your Streamlit data-driven applications, enabling you to create more dynamic and interactive user experiences.\n\n## Installation\n\n`pip install streamlit-oauth`\n\n## Getting started\n\nTo use Streamlit OAuth, you need to create an OAuth2 component with your authentication details (set your callback url to `https://\u003cYOUR ADDRESS\u003e/component/streamlit_oauth.authorize_button`):\n\n```python\nimport streamlit as st\nfrom streamlit_oauth import OAuth2Component\nimport os\n\n# Load environment variables from .env file\nfrom dotenv import load_dotenv\nload_dotenv()\n\n# Set environment variables\nAUTHORIZE_URL = os.environ.get('AUTHORIZE_URL')\nTOKEN_URL = os.environ.get('TOKEN_URL')\nREFRESH_TOKEN_URL = os.environ.get('REFRESH_TOKEN_URL')\nREVOKE_TOKEN_URL = os.environ.get('REVOKE_TOKEN_URL')\nCLIENT_ID = os.environ.get('CLIENT_ID')\nCLIENT_SECRET = os.environ.get('CLIENT_SECRET')\nREDIRECT_URI = os.environ.get('REDIRECT_URI')\nSCOPE = os.environ.get('SCOPE')\n\n# Create OAuth2Component instance\noauth2 = OAuth2Component(CLIENT_ID, CLIENT_SECRET, AUTHORIZE_URL, TOKEN_URL, REFRESH_TOKEN_URL, REVOKE_TOKEN_URL)\n\n# Check if token exists in session state\nif 'token' not in st.session_state:\n    # If not, show authorize button\n    result = oauth2.authorize_button(\"Authorize\", REDIRECT_URI, SCOPE)\n    if result and 'token' in result:\n        # If authorization successful, save token in session state\n        st.session_state.token = result.get('token')\n        st.rerun()\nelse:\n    # If token exists in session state, show the token\n    token = st.session_state['token']\n    st.json(token)\n    if st.button(\"Refresh Token\"):\n        # If refresh token button is clicked, refresh the token\n        token = oauth2.refresh_token(token)\n        st.session_state.token = token\n        st.rerun()\n\n```\n\nmore examples can be found in the [examples](https://github.com/dnplus/streamlit-oauth/tree/main/examples)\n\n**Parameters:**\n\n* `client_id`: The OAuth2 client id provided by the authorization server.\n* `client_secret`: The OAuth2 client secret provided by the authorization server.\n* `authroize_endpoint`: The authorization endpoint URL of the OAuth2 server. (Deprecated for typo.)\n* `authorize_endpoint`: The authorization endpoint URL of the OAuth2 server.\n* `token_endpoint`: The token endpoint URL of the OAuth2 server.\n* `refresh_token_endpoint`: The refresh token endpoint URL of the OAuth2 server.\n* `revoke_token_endpoint`: The revoke token endpoint URL of the OAuth2 server.\n* `client`: The httpx_oauth client to be used for the requests, default is None, if specified other arguments will be ignored.\n\n### `authorize_button(self, name, redirect_uri, scope, height=800, width=600, key=None, extra_params={}, pkce=None, use_container_width=False, icon=None)`\n\nGenerates an HTML button that initiates the OAuth2 authorization code grant flow. The button opens a popup window that prompts the user to authorize the application.\n\n**Parameters:**\n\n* `name`: The name to be displayed on the button.\n* `redirect_uri`: The URL where the authorization server will redirect the user after the authorization process is completed.\n* `scope`: The OAuth2 scopes required by the application.\n* `height`: The height of the popup window.\n* `width`: The width of the popup window.\n* `key`: The unique key of the button component.\n* `extra_params`: A dictionary containing extra parameters to be sent to the authorization server.\n* `pkce`: accept value `S256` indicating whether to use PKCE (Proof Key for Code Exchange) for the authorization code grant flow.\n* `use_container_width`: If `True`, set the button width to the container width.\n* `icon`: The icon to be displayed on the button.\n* `auto_click`: If `True`, the button will be clicked automatically.\n\n**Returns:**\n\n* A dictionary containing the authorization code or access token object, depending on the flow.\n\n### `refresh_token(self, token, force=False)`\n\nRefreshes the access token using the refresh token. If the token is not expired, the function returns the same token.\n\n**Parameters:**\n\n* `token`: The access token object to be refreshed.\n* `force`: A boolean value that forces the refresh token to be used, even if the access token is not expired.\n\n**Returns:**\n\n* A dictionary containing the new access token or the same access token if it has not expired.\n\n### `revoke_token(self, token, token_type_hint='access_token')`\n\n**Parameters:**\n\n* `token`: The access token object to be revoked.\n* `token_type_hint`: A hint about the type of the token submitted for revocation.\n\n**Returns:**\n\n* A boolean value indicating whether the token was revoked successfully.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnplus%2Fstreamlit-oauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnplus%2Fstreamlit-oauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnplus%2Fstreamlit-oauth/lists"}