Discord Oauth2 Join Guild Discord Oauth2 Join Guild express express

Discord Oauth2 Join Guild


I just had to replace the "ContentType" to "Content-Type" in the headers!

headers: {  "Authorization": "Bot [botToken]",  "Content-Type": "application/json",}


A 401 error would mean that you haven't provided the correct scope for the oauth link. Read more about Discord's OAuth scopes over at https://discordapp.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes. Quoting the docs, you would need the guilds.join scope.

Moreover, the docs quote:

guilds.join and bot require you to have a bot account linked to your application. Also, in order to add a user to a guild, your bot has to already belong to that guild.

So make sure your app fulfills the above requirement.

If you have made sure that you have followed the above steps, and you still cannot get it working, you would have to share the OAuth link with us to help you investigate further


You should add user token into the body,Like this:

{  method: 'PUT',  access_token: "Bearer TOKEN"  headers: {    Authorization: `Bot TOKEN`,}

user token should be like this : TiaRZjWv5YAp80MpTFRkhi1GhXqddB