Skip to main content

Ladies and gentlemen, I present to you...

The Unofficial Devpost OAuth Library

Devpost doesn't have an authentication system (I wonder why?). So, I made one. How does it work?

How It Works

This project uses sqlite3 for the database and flask_socketio for the main "logging in" code. When a user logs on the page, a session is made with a unique UUID (a UUID, or a universally unique identifier, is a 128-bit label used for information). The user logs in by dragging a link into their bookmarks bar, then pressing it when they are on a Devpost window. The user is logged in, and can now delete the bookmark from their bookmarks bar.

Challenges I Ran Into

I have used SQL before, but not python's sqlite3 library, so I spent a good piece of my time figuring how to use it. I have used flask a lot before, so flask_socketio was easier than sqlite3, but it was still confusing.

Accomplishments That I'm Proud Of

I actually finished the project (yay 🎉)! I was only planning to make a demonstration website on how the OAuth could be done, but I realized that wouldn't help you that much, as no one could use it. I decided to make a python and javascript 🌐 library for other developers' usage.

The Python 🐍 Library

from flask_devpost_oauth import DevpostAuth
from flask import Flask, render_template
from flask_socketio import SocketIO

app = Flask(__name__)
socketio = SocketIO(app)
DevpostAuth(app, socketio)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/login')
def index():
    return render_template('login.html')

if __name__ == "__main__":
    socketio.run(app, host='0.0.0.0', debug=True)
Installation is pip install flask_devpost_oauth.

The code above is an example. You must pass both your socketio and flask app. If you are not using flask_socketio, just create and run the app, it won't affect your flask app. Using the library is as simple as that! The user information is "given" to the javascript code, not the flask app.

The JavaScript 🌐 Library

<a id="bookmark">Bookmark me!</a>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>
<script src="https://devpost-oauth-static.epiccodewizard.repl.co/script.js"></script>
<script>
    function infofunc(info) {
        alert(info);
    }
    main("https://mywebsite.com/", "bookmark");
    getinfo(infofunc);
</script>
Installation is just using the script tag above.

The code above is an example HTML webpage. Because the time of the user login is unknown, the information is processed by a function, which takes in one argument, info. The information is alerted, in this case. "https://mywebsite.com/" is the URL of the flask server, using the python library. As explained earlier, the user clicks and drags the link, which is inserted in the link tag with the ID specified. In this case, the provided ID is "bookmark", which will get hyperlinked. Note: In this case, socket.io.js is version 2.2.0, but it can de any 1.x and 2.x version.

What I Learned

I definitely learned a lot from this project. I learned a lot about web sockets and databases. This project was very fun to make, and I hope it helps other developers implement this in their own projects.

Additional: Where does the information come from?

In a previous hackathon, I made a Devpost user information API, which gets all the possible information off a user's page. This library queries my API, returning information from it.

That's it, ladies and gentlemen, thank you for your time....

Official Demo

Metadata

Release files for flask-devpost-oauth 1.0.0

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

Source distribution (sdist)

Source distribution for flask-devpost-oauth 1.0.0
File Size Uploaded Provenance Actions
flask_devpost_oauth-1.0.0.tar.gz 4.7 kB Without provenance Details for flask_devpost_oauth-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flask-devpost-oauth 1.0.0
File Interpreter ABI Platform Actions
flask_devpost_oauth-1.0.0-py3-none-any.whl Python 3 none any Details for flask_devpost_oauth-1.0.0-py3-none-any.whl

Total release size: 9.4 kB

Release files / flask_devpost_oauth-1.0.0.tar.gz

Download URL flask_devpost_oauth-1.0.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
40ebb5663dbc5ac166e8a29d602d43349f4a7f0bf4b5ecbcd47830a3d939567e
BLAKE2b-256 checksum
How to use checksums
5d6b23d12190fa4dc90e9eb572c27361734bc3f9110c47df007da533855abbb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/3.10.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.12

Release files / flask_devpost_oauth-1.0.0-py3-none-any.whl

Download URL flask_devpost_oauth-1.0.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50bde43b3f63285364aedb328e8cb38cf56d17faac7b807e6cdf0a87b5d0e82b
BLAKE2b-256 checksum
How to use checksums
88e3868314067f824fa7d06c2179f1fd002dfb253728efd4f5b4f48adebeb55d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/3.10.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.12

Security for flask-devpost-oauth 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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