ReplAuth is one of the most useful things if you're doing a big project w/ replit! Replit has two ReplAuths.
Using the Auth is the most easiest thing in the world. First we have our main.py file. First we create a new Flask app :
Import Flask and create new Flask app
from flask import Flask, render_template, request
app = Flask('app')
@app.route('/')
And then we request the headers :
Requested Headers :
def hello_world():
print(request.headers)
return render_template(
'index.html',
user_id=request.headers['X-Replit-User-Id'],
user_name=request.headers['X-Replit-User-Name'],
user_roles=request.headers['X-Replit-User-Roles'],
user_bio=request.headers['X-Replit-User-Bio'],
user_profile_image=request.headers['X-Replit-User-Profile-Image'],
user_teams=request.headers['X-Replit-User-Teams'],
user_url=request.headers['X-Replit-User-Url']
)
In this code we've requested all the possible headers, which are these :
All Replit Headers
X-Replit-User-Bio
X-Replit-User-Id
X-Replit-User-Name
X-Replit-User-Profile-Image
X-Replit-User-Roles
X-Replit-User-Teams
X-Replit-User-Url
We can show this by displaying the variable assined to a header in a html tag. It can also be showed with out a tag. If we wanted to show the username of the user we would put this :
<h1>{{ user_name }}</h1>
And the answer the output will be a heading (h1) with the username.
The question is in a quote and in italic and the answer is in a bullet point.
ReplAuth FAQ
How many ReplAuths are there?
- There are 2 repl auths!
Which ReplAuths are there?
- Node.js and Python Flask
Is there a Replit Documentation on ReplAuths?
- Yes! You can find it in the Replit Docs
Name : Python Flask ReplAuth
Description : The Python Flask ReplAuth is easy and useful to use! What are you waiting for? Start using the ReplAuth today!
If you found any error, want to give feedback or have any question feel free to do any of these things :
- Comment on the template repl
- DM me on Discord (Hugoonreplit#7284)
- Mail me at [email protected]
If you would like other options to get help you could try some of these :
- Checking the Replit Docs
- Making a topic asking for help on Ask
- Asking for help on the Replit Discord
All errors/feedback/Questions is appreciated!