Twitter external login with Owin gives HTTP 403 (Forbidden)

余生颓废 提交于 2019-11-30 13:27:16

We had a similar issue in the past week or two and found that Twitter, while previously not validating the callback URL, have started checking it.

The login flow for Twitter is like this:

  1. Client calls your backend.
  2. Backend calls Twitter API with callback URL, keys, etc.
  3. Twitter issues a login URL.
  4. Backend redirects client to login URL as a result of the challenge.
  5. Client logs in on Twitter (and authorises the app)
  6. Twitter redirects to the callback URL (usually https://www.example.com/signin-twitter unless you specify an alternative callbackPath)
  7. Backend receives Twitter tokens.

The callback URL validation happens at #2 and will return a 403 to the client if it fails.

I note in your image that your callbackPath is /twittersignin but you're not configuring it on the ASP.NET side, so ASP.NET is using /signin-twitter. You should update your callback URLs on Twitter (via the developer portal) to reflect this.

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