Question

I read the Google Oauth2 documentation and it seems that I can send a login_hint parameter as part of the authorization request, similar to specifying access_type.

I am using an offline access_type for a web server application (Rails application).

I tried setting the parameter on the Client's authorization object as well as passing it as an option when initializing the client but it never auto-fills the login box nor is sent as a query parameter.

All I'm trying to do is, if the user is logged in to Gmail already with a different account then they should be prompted to login / select a different account (which is specified in the login_hint).

Was it helpful?

Solution

I got it working by setting the login_hint parameter using the additional_parameters hash which is available on Signet::OAuth2::Client.

Basically, doing the following:

client = Google::APIClient.new(application_name: 'test application', application_version: '0.0.1')
client.authorization.additional_parameters[:login_hint] = 'some_address@gmail.com'

If you get an error about additional_parameters not being defined then make sure you are using a recent version of the signet gem or use the latest from the master branch.

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