servicestackservicestack-razor

Creating Google Sign In Authentication in Service Stack


I know Service Stack offers a plugin to incorporate google sign in but we are on old version of service stack so we are creating the flow ourselves. We have a custom CredentialsAuthProvider where we are overriding TryAuthenticate and other methods according to our needs.

I could get the Id token from google apis but now I want to pass that to our custom credentailsAuthProvider which does multiple things including creating session and inserting rows into the database.

But I am facing a issue that it keeps failing the validation because I am passing an empty string for password and also I would like to tell my TryAuthenticate method that this request is coming from OAuth like a boolean?

Is there a way to hit TryAuthenticate without a password? Also, is this the right approach for Google Authentication in Service Stack?


Solution

  • TryAuthenticate only exists when trying to create a custom CredentialsAuthProvider, for creating a custom OAuth Provider you should be inheriting GoogleAuthProvider or its OAuth2Provider base class instead.