angularjsauthenticationtwitterservicestackservicestack-auth

Twitter Authentication in ServiceStack


I added twitter Authentication in my ServiceStack Service. My Authentication as well as Service is working fine and i am getting redirected to my Service Page from Twitter Authentication page with success response. But i am not able to integrate this whole with my User Interface. There on button click event i want to successfully authenticated from twitter and after that want to get response from my service based on that i would redirect to my second webpage. Here is my web.config code..

<appSettings>
<!-- servicestack oauth config -->
<add key ="oauth.twitter.ConsumerKey" value="yqeybHSZLzNZjXXtA44XZQ" />
<add key ="oauth.twitter.ConsumerSecret" value="dPHZv3V28OtbK93FM54upAtzoEymLQMbtBqufPuL4" />
<!-- local dev config -->
<add key ="oauth.twitter.RedirectUrl" value="http://localhost:64132/Login" />
<add key ="oauth.twitter.CallbackUrl" value="http://localhost:64132/auth/twitter" />

Once the twitter Authentication is done i want my login page to redirect to http://localhost:49661/Views/Home.html.

Here is how i am trying to do using angular JS but its not happening . Authentication is happening but i am not getting Service response alert and neither able to navigate to second webpage.

$window.location.href = 'http://localhost:64132/auth/twitter';

$http.get("http://localhost:64132/Login")
.success(function (response) { alert(response.loginMessage); });

Please help me .Thanks..


Solution

  • See this previous answer on different ways to specify the redirect url after authentication, e.g you can use the ?Continue=/Home parameter to specify where to redirect to after authentication.

    Note if you're using ServiceStack.Razor feature, the /Views folder is a special location for View Pages which can't be redirected to directly, i.e. they're the View Page rendered as a result of calling a Service, e.g. /home. Anything outside /Views is a Content Page that can be requested directly.