I've managed to fix the 401 problem. Thanks for helping out with that guys!
One more issue that is more of a luxury feature that I would really like to add:
Right now after logging in with Discord for the first time it still prompts me to enter a username and email address to register. What I would like to happen is to skip this and to have the credentials retrieved from Discord to be immediately used for this process. I don't want the user to manually enter a username and email afterwards. Is this possible and if so how? I looked through the code that handles the request after logging in but it only seems to check if there is a user that already exists with the same email, but not if its possible to immediately register if the $suggestions and $identification provide sufficient info.