Hieu Le
Hieu Le

Reputation: 1132

Can Not Use Twitter Authentication

I am implement Authentication for Twitter by ASP.NET MVC.

app.UseTwitterAuthentication(new TwitterAuthenticationOptions()
{
       ConsumerKey = "XXX",
       ConsumerSecret = "XXX",
});

When I clicked the link http://localhost:55586/Account/Login?ReturnUrl=%2F I met a error as below image: I don't know I missed somethings or not. [enter image description here]

Upvotes: 0

Views: 485

Answers (1)

Hieu Le
Hieu Le

Reputation: 1132

Thank you, everyone. Finally, I found a solution.

Step 1:

app.UseTwitterAuthentication(new TwitterAuthenticationOptions()
{
    ConsumerKey = "XXX",
    ConsumerSecret = "XXX",
    BackchannelCertificateValidator = new Microsoft.Owin.Security.CertificateSubjectKeyIdentifierValidator(new[]
    {
       "A5EF0B11CEC04103A34A659048B21CE0572D7D47", // VeriSign Class 3 Secure Server CA - G2
       "0D445C165344C1827E1D20AB25F40163D8BE79A5", // VeriSign Class 3 Secure Server CA - G3
       "7FD365A7C2DDECBBF03009F34339FA02AF333133", // VeriSign Class 3 Public Primary Certification Authority - G5
       "39A55D933676616E73A761DFA16A7E59CDE66FAD", // Symantec Class 3 Secure Server CA - G4
       "‎add53f6680fe66e383cbac3e60922e3b4c412bed", // Symantec Class 3 EV SSL CA - G3
       "4eb6d578499b1ccf5f581ead56be3d9b6744a5e5", // VeriSign Class 3 Primary CA - G5
       "5168FF90AF0207753CCCD9656462A212B859723B", // DigiCert SHA2 High Assurance Server C‎A 
       "B13EC36903F8BF4701D498261A0802EF63642BC3" // DigiCert High Assurance EV Root CA
     }),
});

Run the project again. I met the error as below: enter image description here

Step 2:

https://apps.twitter.com/
Go to the Settings Tab Set a Callback URL to any website. Even if it is not real

=> I set it to http://google.com enter image description here

Then, It works for me. I don't know why I need to set Callback URL. After I set any value into it, I cannot set empty value. So, I think it's an error of Twitter API.

asp-net-mvc-5-owin-twitter-auth-throwing-401-exception

Upvotes: 2

Related Questions