Brings replit auth to flask.
Project description
The Unofficial Replit Auth Flask Extension
Replit authentication is an amazing thing. It is a bit confusing, though, to get information. This package provides an easy way to do so.
@app.route("/")
def index():
if request.user:
return request.user['username']
else:
return 'Not logged in!'
Imports:
from flask import request
from flask_replit_auth import replit_auth
Initialize replit auth on your app by calling replit_auth(app)
after making your flask app.
To get information, call request.user
in any of your functions. It will either return None
, or a dict
with the information.
Replit Auth - Frontend
var button = document.getElementById('login_with_replit');
if (location.protocol !== 'https:') {
alert('Replit auth requires https!');
}
button.onclick = function() {
window.addEventListener('message', authComplete);
var h = 500;
var w = 350;
var left = (screen.width / 2) - ( w / 2);
var top = (screen.height / 2) - (h / 2);
var authWindow = window.open('https://repl.it/auth_with_repl_site?domain=' + location.host, '_blank', 'modal=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left)
function authComplete(e) {
if (e.data !== 'auth_complete') {
return;
}
window.removeEventListener('message', authComplete);
authWindow.close();
// Reload the page to get the credentials.
location.reload();
}
}
Usage:
- Apply the code above to your HTML file.
- Set the
id
of you login button tologin_with_replit
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for flask_replit_auth-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6ebed3aa2a212d836a0081d7986c5e15c043aca81436c28f5f75075ea91ce7a |
|
MD5 | e2b4413647acfb9cde2b56108c45c380 |
|
BLAKE2b-256 | 79ad6a781ceda6296a34dc9f4f4bb6483517bc3b5a718537b4e2854e14f9da09 |