Using OAuth in a ServiceStack Client

I got confused trying to use OAuth (facebook / twitter) on the client and then authenticate with ServiceStack. all the examples that I see for authentication in the client use basic auth, for example:

var response = _client.Send<AuthResponse>(new Auth { provider = CredentialsAuthProvider.Name, UserName = model.Username, Password = model.Password, RememberMe = true }); 

What do I need to do to authenticate my offline client using facebook? I call the FB and get the UID, access token, email, etc., and then what is the call to the service stack for authentication?

Currently, I believe that you need to authenticate using FB on the client, call the service to check if the user exists (looking at the email address). if they do not register and do not register them, using the hash of some of their data as a password. if they exist, register them in the same way. Is this a reasonable / best practice?

early

+8
oauth servicestack
source share
1 answer

What do I need to do to authenticate my offline client using facebook? What is a call to authenticate a service?

You can handle authentication on ServiceStack and Facebook using FacebookAuthProvider ( https://github.com/ServiceStack/ServiceStack/wiki/Authentication-and-authorization ). Posting a request ** to '/ auth / facebook' (provided by the ServiceStack endpoint) will authenticate with ServiceStack and Facebook. In ServiceStack, you can access Facebook tokens using UserSession.GetOAuthTokens("facebook") . I think you can share these tokens with your client or ask your client to go through the ServiceStack endpoints (which you create) to access Facebook. Similar to how TwitterGateway ( https://github.com/ServiceStack/SocialBootstrapApi/blob/master/src/SocialBootstrapApi/Logic/TwitterGateway.cs ) works in the SocialBootStrapApi example.

** {"UserName":"yourname", "Password":"yourpassword", "RememberMe":true/false}

+2
source share

All Articles