Skip to main content

WordPress Authentication for Streamlit

  • Please note that in order to use this package, you need a WordPress website that supports the JWT Authentication plugin. To get started, you will first need to install the WordPress Plugin. Here is the GitHub page where you can find the WordPress Plugin: WordPress Streamlit Integration Plugin

After installing the WordPress Plugin, you can proceed with the installation of the Python

This Python package allows users of a Streamlit app to authenticate with a WordPress website via JSON Web Tokens (JWT).

Installation

Install the package via pip:

pip install wordpress-auth

First, you need to create an instance of the WordpressAuth class. You'll need to provide your API keys and the base URL of your WordPress site:

from wordpress_auth import WordpressAuth

auth = WordpressAuth(api_key='YOUR_API_KEY', base_url='https://yourwordpressurl.com')

Now, you can use the get_token and verify_token methods to retrieve and verify a token:

token = auth.get_token(username, password)
if token and auth.verify_token(token):
    # The user is authenticated.

Integration into a Streamlit App You can use this package in a Streamlit app to create a login form:

import streamlit as st
from wordpress_auth import WordpressAuth

# Set your WordPress site base URL and API key here.
auth = WordpressAuth(api_key='YOUR_API_KEY', base_url='https://yourwordpressurl.com')

def main():
    st.write("This is the main page of the application.")  # Your main code goes here

# Check if the user is already logged in
if 'token' in st.session_state and auth.verify_token(st.session_state['token']):
    main()  # Call the main function
else:
    # Show the login form
    with st.form(key='login_form'):
        st.title("Please log in")
        username = st.text_input('Username')
        password = st.text_input('Password', type='password')
        submit_button = st.form_submit_button(label='Log in')

        if submit_button:
            token = auth.get_token(username, password)
            if token and auth.verify_token(token):
                st.session_state['token'] = token  # We store the token in the session state
                st.experimental_rerun()  # Reload the page so that the login form disappears
            else:
                st.error('Access denied')

Please note that in order to use this package, you need a WordPress website that supports the JWT Authentication plugin. You also need to have a valid API key.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Contact

For any queries or suggestions, feel free to contact me:

Keyvan Hardani Email: hello@keyvan.ai GitHub: https://github.com/Keyvanhardani/streamlit-wordpress-authentication Please ensure to replace all placeholder text with actual values.WordPress Authentication for Streamlit This Python package allows users of a Streamlit app to authenticate with a WordPress website via JSON Web Tokens (JWT).

Installation

Install the package via pip:

pip install wordpress-auth

First, you need to create an instance of the WordpressAuth class. You'll need to provide your API keys and the base URL of your WordPress site:

from wordpress_auth import WordpressAuth

auth = WordpressAuth(api_key='YOUR_API_KEY', base_url='https://yourwordpressurl.com')

Now, you can use the get_token and verify_token methods to retrieve and verify a token:

token = auth.get_token(username, password)
if token and auth.verify_token(token):
    # The user is authenticated.

Integration into a Streamlit App You can use this package in a Streamlit app to create a login form:

import streamlit as st
from wordpress_auth import WordpressAuth

# Set your WordPress site base URL and API key here.
auth = WordpressAuth(api_key='YOUR_API_KEY', base_url='https://yourwordpressurl.com')

def main():
    st.write("This is the main page of the application.")  # Your main code goes here

# Check if the user is already logged in
if 'token' in st.session_state and auth.verify_token(st.session_state['token']):
    main()  # Call the main function
else:
    # Show the login form
    with st.form(key='login_form'):
        st.title("Please log in")
        username = st.text_input('Username')
        password = st.text_input('Password', type='password')
        submit_button = st.form_submit_button(label='Log in')

        if submit_button:
            token = auth.get_token(username, password)
            if token and auth.verify_token(token):
                st.session_state['token'] = token  # We store the token in the session state
                st.experimental_rerun()  # Reload the page so that the login form disappears
            else:
                st.error('Access denied')

Please note that in order to use this package, you need a WordPress website that supports the JWT Authentication plugin. You also need to have a valid API key.

License This project is licensed under the MIT License - see the LICENSE.md file for details.

Metadata

Release files for wordpress-auth 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wordpress-auth 0.2
File Size Uploaded
wordpress-auth-0.2.tar.gz 3.0 kB Details

Release files / wordpress-auth-0.2.tar.gz

Download URL wordpress-auth-0.2.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ee3e313acb196163b4e7e467a204dc0fa7933baa834387f3204e47b3b2d81f54
BLAKE2b-256 checksum
How to use checksums
81cac9f8ef88678a09e22f9a09564d55892b081b25c139a1eb1d6738d8a2f58b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page