How to Prefill Google API Oauth2 Login with Credentials

465 Views Asked by At

I have a question regarding Oauth2 login for Google API. Suppose my application knows the credentials of user (stored securely somewhere in my app's database), is there a way to bypass the login screen by prefilling the username and password from the backend in someway so that the Oauth2 confirmation screen to get the access token only shows the scope permissions confirmation?

1

There are 1 best solutions below

0
Shaun the Sheep On

One of the main benefits of OAuth2 is that it allows a user to give your application access to some resource or other without having to supply their login credentials. The exception is the "password" grant which allows the client application to act on the user's behalf, but is generally discouraged.

Google's login screen is loaded from their site, so you can't control the data that it renders or bypass it. One of the other important things about OAuth is that the user usually gets to decide whether to grant access or not. If the user has previously granted access to your application, and is already logged in to Google, then they will probably be redirected without having to log in again.

You shouldn't really be storing a user's Google credentials on your site - no matter how secure you think they are - one of the main reasons standards like OAuth exist is to avoid just this situation.