We use Reddit's Oauth flow to get a user access_token
, to then check against their /api/v1/me
endpoint, to confirm ownership of a user account. This user account is then stored in our db, and a cookie is returned with a JWT encoding basic info about their account (reddit name, icon, and our id for them).
- Navigate user to
/api/login
. - Redirect user to
https://www.reddit.com/api/v1/authorize
to get a code to our redirect uri. - Reddit redirects to our redirect uri
/api/oauth/redirect/reddit
. - Request an
access_token
fromhttps://www.reddit.com/api/v1/access_token
with the code received. - Use
access_token
to get result ofhttps://oauth.reddit.com/api/v1/me
. - Create update/our user as necessary.
- Add cookie with JWT signed with a secret to the response.
- Redirect user to
/
.