HttpRequestException: Response status code does not indicate success: 401 (Authorization Required)


#1

Trying to create a simple OAuth demo on my local IIS server.

Using Visual Studio 2013, I’ve created a new ASP.NET Web Application (using the MVC template) and have chosen Individual User Accounts for my authentication mode.

The Startup.Auth.cs file, contains the following two lines of code:

        app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
        {
            ClientId = "****.apps.googleusercontent.com",
            ClientSecret = "****"
        });

        app.UseTwitterAuthentication(
           consumerKey: "*****",
           consumerSecret: "****");

I was able to successfully authentication against Google on the first try. However, for some reason, I can’t figure out how to get Twitter to work.

What I’ve Done So Far

I’ve figured out how to create a Twitter application and I’ve checked the “Allow this application to be used to Sign in with Twitter”.

Under the API Keys tab, I’ve copied the API Key string to comsumerKey and the API secret to the comsumerSecret fields. But when I run the sample application I keep getting back the following error message.

Request From: https://localhost:44300/Account/ExternalLogin
Response: HttpRequestException: Response status code does not indicate success: 401 (Authorization Required).

I’ve also tried using cURL by copying and pasting the string I got from the “Get OAuth Signature” section. However, cURL responded with: "Bad Authentication data".

What am I doing wrong?

Thanks!


#2

The fix for this is very simple. Set the callback url to any website address. It works. I faced similar issue.