Question

I've been trying to add the OAuth2 provider for Google to a proof of concept application built on ServiceStack however I keep getting the following error when I try to initiate a login...

This method requires a current HttpContext. Alternatively, use an overload of this method that allows you to pass in information without an HttpContext`enter code here`

[Auth: 11/21/2013 10:29:25 PM]: [REQUEST: {provider:googleoauth}] System.InvalidOperationException: This method requires a current HttpContext. Alternatively, use an overload of this method that allows you to pass in information without an HttpContext. at DotNetOpenAuth.Requires.ValidState(Boolean condition, String message) at DotNetOpenAuth.Messaging.Channel.GetRequestFromContext() at DotNetOpenAuth.OAuth2.WebServerClient.ProcessUserAuthorization(HttpRequestBase request) at ServiceStack.Authentication.OAuth2.OAuth2Provider.Authenticate(IServiceBase authService, IAuthSession session, Auth request) at ServiceStack.ServiceInterface.Auth.AuthService.Authenticate(Auth request, String provider, IAuthSession session, IAuthProvider oAuthConfig) at ServiceStack.ServiceInterface.Auth.AuthService.Post(Auth request) at ServiceStack.ServiceInterface.Auth.AuthService.Get(Auth request) at lambda_method(Closure , Object , Object ) at ServiceStack.ServiceHost.ServiceRunner`1.Execute(IRequestContext requestContext, Object instance, TRequest request)

I've also downloaded the demo app SocialBootstrapApi and added the Google Oauth2 provider to it and was able to get it to work. I've copied over the config from the web.config into the app.config file of the self hosted project but it still doesn't work.

Any help would be great!

Thanks for the help.

Was it helpful?

Solution

The ServiceStack.AuthWeb.Tests is an ASP.NET WebHost showing all the ServiceStack AuthProviders working within a single app.

Note the OAuth2 providers use additional configuration specified in the Web.config which requires that you register your own application to get your Consumer Key and Secret for your app. For testing purposes you can use the ServiceStack Test keys already embedded in the Web.config.

The OAuth2 section in the Authentication wiki provides the urls where you can register your application for each provider.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top