Saturday, 15 January 2011

servicestack - /auth/twitter not found -



servicestack - /auth/twitter not found -

i working on implementing twitter authentication servicestack implementation. using social bootstrap api found here reference.

in apphost have next code:

class="lang-cs prettyprint-override">var appsettings = new appsettings(); plugins.add(new sessionfeature()); plugins.add(new authfeature( () => new authusersession(), new iauthprovider[] { new twitterauthprovider(appsettings) }));

the next options specified in web.config; oauth.twitter.consumerkey, oauth.twitter.consumersecret, oauth.twitter.redirecturl, , oauth.twitter.callbackurl.

i using next code in unit test test twitter authentication:

class="lang-cs prettyprint-override">var authenticate = restclient.post<authservice>( "/auth/twitter?format=json", new auth() { username = "username", password = "password", rememberme = true });

/auth/credentials works fine sql based authentication setup (i removed line registering custom authprovider sample above). receive 'not found' error /auth/twitter endpoint.

is there missing? understanding authentication endpoints available @ /auth/[provider].

i using service stack version 3.9.35.0 asp.net web forms project in visual studio 2012.

not sure if it's relevant servicestack's socialbootstrap api asp.net mvc application servicestack hosted @ /api. if you're getting 404 seek prefixing route /api/.

the twitter, facebook auth , other open id providers in servicestack requires html redirects , manual acceptance isn't able tested normal c# integration test.

basically need utilize selenium allows total end-to-end integration test can simulate user using browser.

other notes:

you never want prefix ?format=json when using c# serviceclient format sent in http accept header every request. don't need specify custom routes services automatically fallback using servicestack's pre-defined routes if no custom route exists.

so if test twitter authentication c# clients, change:

var restclient = new jsonserviceclient(...); var authenticate = restclient.post<authservice>( "/auth/twitter?format=json", new auth() { username = "username", password = "password", rememberme = true });

to more succinct version:

var restclient = new jsonserviceclient(...); var authenticate = restclient.post(new auth { provider = "twitter", username = "username", password = "password", rememberme = true });

servicestack

No comments:

Post a Comment