/ auth / twitter not found

I am working on implementing Twitter authentication in my ServiceStack implementation. I am using the Social Bootstrap API found here for reference.

In my apphost, I have the following code:

var appSettings = new AppSettings();
Plugins.Add(new SessionFeature());
Plugins.Add(new AuthFeature(
    () => new AuthUserSession(), 
    new IAuthProvider[] 
    { 
        new TwitterAuthProvider(appSettings)
    }));

      

In my web.config

specify the following parameters: oauth.twitter.ConsumerKey

, oauth.twitter.ConsumerSecret

, oauth.twitter.RedirectUrl

and oauth.twitter.CallbackUrl

.

I am using the following code in my unit test for Twitter authentication:

var authenticate = restClient.Post<AuthService>(
    "/auth/twitter?format=json",
    new Auth()
    {
        UserName = "username",
        Password = "password",
        RememberMe = true
     });

      

/auth/credentials

Works great for SQL based IIS setup (I removed the line registering my custom one AuthProvider

for the sample above). I am getting a "Not Found" error for the endpoint /auth/twitter

.

Is there something I am missing? I understand that authentication endpoints are available in /auth/[provider]

.

I am using Service Stack version 3.9.35.0 with an ASP.NET Web Forms project in Visual Studio 2012.

+3


source to share


1 answer


Not sure if this is relevant, but the ServiceStack SocialBootstrap API is an ASP.NET MVC application with a ServiceStack hosted in / api . So if you get a 404 try prefixing your route with /api/

.

Twitter, Facebook Auth and all the other Open Id providers in ServiceStack require html redirects and manual reception, so cannot be tested like a normal C # integration test.

Basically, you will need to use something like Selenium , which will allow you to run a full end-to-end integration test that can simulate a user using a browser.

Other Notes:

Do you ever want a prefix ? format = json when using C # ServiceClient as the format is already sent in the HTTP Accept header with every request. Also, you usually don't need to specify custom routes, as services are automatically rolled back to using the predefined ServiceStack routes if there is no custom route.



So, if you can check twitter authentication using C # clients, you can change:

var restClient = new JsonServiceClient(...);
var authenticate = restClient.Post<AuthService>(
"/auth/twitter?format=json",
new Auth()
{
    UserName = "username",
    Password = "password",
    RememberMe = true
 });

      

to this more concise version:

var restClient = new JsonServiceClient(...);
var authenticate = restClient.Post(new Auth {
    provider = "twitter",
    UserName = "username",
    Password = "password",
    RememberMe = true
});

      

+3


source