Force google to show account chooser and consent screen

5.6k Views Asked by At

I am able to use both prompt=consent and prompt=select_account individually, but Google doesn't seem to allow me to combine them. I tried the prompt=consent+select_account as suggested in an answer of Force google account chooser, but that fails with the error: "Invalid prompt: consent+select_account".

The doc (https://developers.google.com/accounts/docs/OAuth2Login) says "A space-delimited list", so I tried consent select_account but that fails with: "The requested URL was not found on this server."

I also tried combining prompt=select_account and approval_prompt=force, but Google doesn't like that either.

Anyone else have luck with combining consent screen and account chooser?

Update:

This is my JavaScript method creating URL for getting contacts from gmail

$scope.importGmailContacts = function() {
    provider = 'gmail';
    $scope.importing_from_gmail = true;
    window.open(protocol + "://" + host + ":" + port + "/contacts/gmail", "_blank",
     "toolbar=yes, scrollbars=yes, resizable=yes, top=0, left=0, width=600, height=600, prompt='select_account+consent', approval_prompt=force");
}

I have tried setting prompt and approval_prompt both collectively and individually but it does not seems to work. Refer to this question.

3

There are 3 best solutions below

0
On

https://accounts.google.com/o/oauth2/auth?client_id=XXXX&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/analytics.readonly&response_type=code&prompt=select_account+consent&approval_prompt=force

Results in the error

  1. That’s an error.

Error: invalid_request

Conflict params: approval_prompt and prompt

Prompt and approval_prompt parameters can not be used together.

prompt Optional.

A space-delimited, case-sensitive list of prompts to present the user. If you don't specify this parameter, the user will be prompted only the first time your app requests access. Possible values are:
none Do not display any authentication or consent screens. Must not be specified with other values.
consent Prompt the user for consent.
select_account Prompt the user to select an account.

If memory serves approval_prompt is the older way of doing it and google added Prompt sometime in 2012. I cant actually find any documentation on approval_prompt anymore but if memory serves it was the same as doing prompt=consent it just requested access again.

0
On

I just tried this and it DID work when space-delimited:

options[:prompt] = 'select_account consent'

1
On

You need add: access_type=online&prompt=select_account+consent:

private static final String AUTHORIZE_URL 
    = "https://accounts.google.com/o/oauth2/auth?"
      + "response_type=code&access_type=online&prompt=select_account+consent"
      + "&client_id=xxx&redirect_uri=xxx";

private static final String SCOPED_AUTHORIZE_URL = AUTHORIZE_URL + "&scope=xxx";

..