I'm using servicestack client in my Android(Java) and iOS(Swift) applications but I need to authenticate users with facebook and google, Do you know if exists a module like Xamarin.Auth https://github.com/xamarin/Xamarin.Auth but for native applications?
Thank you
Have a look at AndroidJavaChat which is a port of the C# Xamarin.Android Chat it explains a couple of different ways of Authenticating with Facebook using their SDK and leveraging the new support for Authenticating using an AccessToken in ServiceStack v4.5.7+ that's now available on MyGet.
First follow this getting started guide to install Facebook's SDK.
Then checkout the implementation for LoginButtonActivity which authenticates using the Facebook Login button which you can define in your Layout.xml with:
Signing in with Facebook Login Button
To use Facebook's SDK your AppId needs to be defined in your AndroidManifest.xml:
Using the
ApplicationIdfor your Facebook App from your App created in https://developers.facebook.com/appsThen you can Authenticate with Facebook Login button by registering a callback on the
LoginButton. After that it's simply a matter of handling the FacebookonSuccess(),onCancel()andonError()callbacks. When theonSuccess()callback is fired it means the User has successfully Signed into our Android App, we then need to Authenticate with our ServiceStack Chat Server by making an Authenticated request using the User's FacebookAccessToken, e.g:Once the User has authenticated with the ServiceStack Server, the Authenticated Session Cookies are configured on the Service Client which you can now use to make authenticated requests.
If you instead want to login using your own Custom Image for your login button, follow the steps in Signing in with Custom Facebook Image Button.
Automatically Sign-In previously Signed In Users
After the User has successfully Authenticated with Facebook the first time you can access their saved token from Facebook's
AccessToken.getCurrentAccessToken()to automatically sign them in for future restarts, e.g: