{"id":23396316,"url":"https://github.com/stuyk/altv-discord-auth","last_synced_at":"2026-03-16T22:02:39.691Z","repository":{"id":40795754,"uuid":"279947880","full_name":"Stuyk/altv-discord-auth","owner":"Stuyk","description":"alt:V Discord Authentication with optional role whitelisting.","archived":false,"fork":false,"pushed_at":"2023-03-13T12:39:40.000Z","size":191,"stargazers_count":32,"open_issues_count":1,"forks_count":14,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-11T11:21:03.194Z","etag":null,"topics":["altv","discord","discord-authentication","discord-bot","discord-developers","fivem","hacktoberfest","ragemp","role-whitelist","whitelist"],"latest_commit_sha":null,"homepage":"https://stuyk.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Stuyk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["stuyk"],"patreon":"stuyk"}},"created_at":"2020-07-15T18:34:28.000Z","updated_at":"2025-02-16T11:45:43.000Z","dependencies_parsed_at":"2025-04-11T14:42:42.886Z","dependency_job_id":"1bb0ac29-b292-4cc0-928e-dbcab4a85b4d","html_url":"https://github.com/Stuyk/altv-discord-auth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Stuyk/altv-discord-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stuyk%2Faltv-discord-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stuyk%2Faltv-discord-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stuyk%2Faltv-discord-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stuyk%2Faltv-discord-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Stuyk","download_url":"https://codeload.github.com/Stuyk/altv-discord-auth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stuyk%2Faltv-discord-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271746755,"owners_count":24813580,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["altv","discord","discord-authentication","discord-bot","discord-developers","fivem","hacktoberfest","ragemp","role-whitelist","whitelist"],"created_at":"2024-12-22T07:34:59.590Z","updated_at":"2026-03-16T22:02:39.623Z","avatar_url":"https://github.com/Stuyk.png","language":"JavaScript","funding_links":["https://github.com/sponsors/stuyk","https://patreon.com/stuyk","https://github.com/sponsors/Stuyk/"],"categories":[],"sub_categories":[],"readme":"[![](https://i.imgur.com/qzftIlN.jpg)](https://www.youtube.com/watch?v=eJfpeqqeUEY)\n\n# alt:V - Discord Authentication with Optional Whitelist\n\n[❤️ Become a Sponsor of my Open Source Work](https://github.com/sponsors/Stuyk/)\n\n[⌨️ Learn how to script for alt:V](https://stuyk.github.io/altv-javascript-guide/)\n\n⭐ This repository if you found it useful!\n\n# Summary\n\nIf you ever wanted to go with a passwordless login or authentication method. This is allows you to utilize Discord to help with user logins by utilize the oAuth2 Service provided by Discord.\n\nThis was meant to be as intuitive as possible but also as secure as we can make it. Which means we utilize an express server to help mitigate fake client-side data.\n\nThis resource requires opening port `7790`.\n\nThis resource requires a Discord Developer Application. (Free)\n\nIf you plan on using the whitelist it requires a Discord Bot. (Free)\n\nThis also comes with an optional whitelist where you can give players a `role` in order to get into the server. The whitelist automatically updates when you add or remove a role from the user. It also automatically re-parses the whitelist every `60` seconds.\n\nLooking for a traditional login with Username and Password? Try out [alt:V OS Auth](https://github.com/Stuyk/altv-os-auth/).\n\n# Prerequisites\n\n**I cannot stress this enough. Ensure you have NodeJS 13+ or you will have problems.**\n\n-   [NodeJS 13+](https://nodejs.org/en/download/current/)\n-   An Existing or New Gamemode\n-   General Scripting Knowledge\n\nAfter simply add the name of this resource to your `server.cfg` resource section. It must be named exactly like this.\n\n\u003e `altv-discord-auth`\n\nThen simply clone this repository into your main server resources folder.\n```\ncd resources\ngit clone https://github.com/Stuyk/altv-discord-auth\n```\n\nAfter cloning, navigate to `resources/altv-discord-auth` directory and simply run `npm install` to install needed dependencies.\n\n# Port Forward\n\nOpen Port 7790 for your express server.\n\n# Generating Your Bot\n\nCreate a Discord Bot at [https://discord.com/developers/](https://discord.com/developers/)\n\n[Click here to see a .gif of the process.](https://gfycat.com/AncientPositiveBobcat)\n\n# Add oAuth2 Redirect\n\nYou will need to add a specific file path to the oAuth2 bot. This setting can be found in the oAuth2 category of the discord developers application.\n\n### Append the Following for Redirects\n\n`http://127.0.0.1:7790/authenticate`\n\n`http://\u003cyour_server_ip\u003e:7790/authenticate`\n\n**Make sure to save!**\n\n# Inviting Your Bot\n\nYou simply visit the oAuth2 section of the discord developers application. Tick `bot` in scopes. Then tick `administrator` in bot permissions (optional just make sure your bot can see all users). After you copy the link and paste it in your browser.\n\n![](https://i.imgur.com/f2yKXnf.jpeg)\n\n# Updating Environment Variables\n\n### MAKE SURE TO READ ALL OF THIS. IT'S VERY IMPORTANT.\n\nOpen your `.env` file which should be located in the same directory as your `altv-server` file. Running this resource without the `.env` will generate it automatically. If you are not sure what a `.env` file is please use google.\n\n```\nENABLE_WHITELIST=false\nCLIENT_ID=\u003cclient_id\u003e\nCLIENT_SECRET=\u003cclient_secret\u003e\nBOT_SECRET=\nSERVER_ID=\nROLE_WHITELIST_ID=\nREDIRECT_IP=127.0.0.1\n```\n\nAnything marked with \\* is OPTIONAL.\n\n\\*=Optional\n\n## ENABLE_WHITELIST\n\nThis will automatically default to false. Meaning it will not turn on the whitelist.\n\nSet this to true to enable the whitelist.\n\n```\nENABLE_WHITELIST=true\nENABLE_WHITELIST=false\n```\n\n## CLIENT_ID\n\nThis can be found under the general information of the discord developers app. Copy the ID that is in plain text.\n\n![](https://i.imgur.com/m60sbzE.jpg)\n\n## CLIENT_SECRET\n\nThis can be found under the general information of the discord developers app. Reveal or copy the secret.\n\n![](https://i.imgur.com/gSKTJBt.jpg)\n\n## REDIRECT_IP\n\n### Running Locally?\n\nIf you are running your server locally and just for yourself. Use localhost.\n\n`ie. 127.0.0.1`\n\n### Running in Production?\n\nIf you are running your server for players to join use the IP for your machine.\n\nEnsure you port forward 7790 in your router, firewall, etc.\n\n## BOT_SECRET \\*\n\nThis can be found under the bot section of the discord developers app. Copy the secret for your bot.\n\n![](https://i.imgur.com/dk38pVl.jpg)\n\n## SERVER_ID \\*\n\nThis can be found by enabling developer mode for Discord.\n\nDiscord App -\u003e Settings -\u003e Appearance -\u003e Scroll Down to Advanced\n\nToggle `ON` Developer Mode\n\nRight-click your server on the left-side and `Copy ID`\n\n![](https://i.imgur.com/999mRsI.jpeg)\n\n## ROLE_WHITELIST_ID \\*\n\nThis can be found by enabling developer mode for Discord.\n\nDiscord App -\u003e Settings -\u003e Appearance -\u003e Scroll Down to Advanced\n\nToggle `ON` Developer Mode\n\nGo to your Server Roles for your Server.\n\nCreate a role called whatever you want. I used `whitelist`\n\nRight-Click the role and select `Copy ID`\n\n![](https://i.imgur.com/Dry1GlD.jpeg)\n\n# Showing the Authentication Window\n\nWhen a player first joins your server you will want to emit this event. We do not do it for you.\n\n**Server-Side**\n```js\nalt.on('playerConnect', playerConnect);\n\nfunction playerConnect(player) {\n    alt.emit('discord:BeginAuth', player);\n}\n```\n\n# After Authentication\n\nThe users general Discord Information will be sent to you through an alt event.\nYou will also recieve the player which it belongs to.\nThe window will automatically close for that user.\n\n**Server-Side**\n```js\nalt.on('discord:AuthDone', playerAuthDone);\n\nfunction playerAuthDone(player, discordInfo) {\n    console.log(discordInfo);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuyk%2Faltv-discord-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstuyk%2Faltv-discord-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuyk%2Faltv-discord-auth/lists"}