Skip to content
Sign upLog in
← Back to Community

Simple chat with authentication

Profile icon

On a whim I made a relatively simple chat - except using's "oauth" authentication system.

How it works

Client sends messages to server, which relays them, along with the username of the sender, to the other clients. Server joins and leaves are also announced. auth

The server checks for the "x-replit-user-name" header when you request the file. By default this header doesn't exist, meaning that you will appear as a "Guest".

When you click the login button, it creates a login popup. When this is completed, a cookie is created with your id, as well as the "x-replit-user-name" HTTP header.

The client then reloads. Now the server checks for the username header again, and finds it! it will now use this username inside the chat as your nickname.

Profile icon
Profile icon

a cookie is created with your id

it's not your replit id's "oauth" authentication system.

it's not oauth

Profile icon


it's not oauth

notice how I quoted oauth
I used that because it's oauth-like to a remote degree, meaning that was probably the simplest explanation.

it's not your replit id

Again, relative
id is the simplest way to explain it, even though it is a session-only token

Thanks for commenting