OAuth2, Using POST and Yet… Method Not Allowed?

本小妞迷上赌 提交于 2019-12-06 19:56:32

You are getting a 405 because you are resolving to the wrong URL for the token endpoint. The library you use sets the tokenurl as:

const tokenUrl = url.resolve(config.auth.tokenHost, config.auth.tokenPath);

So:

url.resolve('https://discordapp.com/api', '/oauth2/token')

will resolve to:

https://discordapp.com/oauth2/token

which will give you a 405 response. I think you just need to add a "/" to the end of your tokenHost value.

i.e. change your config to:

    "auth": {
        "tokenHost": "https://discordapp.com/api/",
        "authorizePath": "/oauth2/authorize",
        "tokenPath": "/oauth2/token",
        "revokePath": "/oauth2/token/revoke"
    } 

or:

    "auth": {
        "tokenHost": "https://discordapp.com",
        "authorizePath": "/oauth2/authorize",
        "tokenPath": "/api/oauth2/token",
        "revokePath": "/api/oauth2/token/revoke"
    } 

and that should correctly resolve the token url.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!