SPA-with-AngularJS icon indicating copy to clipboard operation
SPA-with-AngularJS copied to clipboard

Login is returning an invalid token

Open tanis2000 opened this issue 9 years ago • 0 comments

I noticed that at this line https://github.com/SoftUni/SPA-with-AngularJS/blob/master/Ads-REST-Services/Ads.Web/Controllers/UserController.cs#L122 you're using the TestServer class to issue the new token. I noticed that the token isn't working if you then pass it to any authorized method.

Instead I replaced that code with:

            HttpClient hc = new HttpClient();
            var request = HttpContext.Current.Request;
            var tokenServiceResponse = await hc.PostAsync(string.Format("{0}://{1}", request.Url.Scheme, request.Url.Authority) + Startup.OAuthOptions.TokenEndpointPath.ToString(), requestParamsFormUrlEncoded);

This way it's actually calling our real /Token route and retrieving a valid token.

tanis2000 avatar Mar 15 '16 14:03 tanis2000