googleapis / google-api-php-client

A PHP client library for accessing Google APIs
Apache License 2.0
9.22k stars 3.52k forks source link

Invalid parameter value for prompt: Invalid prompt: consent; #2444

Closed anibalsanchez closed 1 year ago

anibalsanchez commented 1 year ago

Hi,

The client authorization has stopped working with the following:

$client->setPrompt('consent');

I have also tried other combinations with the following:

$client->setApprovalPrompt('force');

or

$client->setApprovalPrompt('consent');

In all cases, it returns: Access blocked: Authorization Error Invalid parameter value for ...

According to the documentation, $client->setApprovalPrompt('consent'); should work. https://developers.google.com/identity/protocols/oauth2/web-server. This is a previous report of similar cases: https://github.com/googleapis/google-api-php-client/issues/1821

Environment details

Steps to reproduce

Code example

$client-> = new \Google\Client();

// $client->setApprovalPrompt('force');
// $client->setPrompt('consent');
$client->setApprovalPrompt('consent');

$client->setAccessType('offline');
$client->setClientId($clientId);
$client->setClientSecret($clientSecret);
$client->setDeveloperKey($developerKey);
$client->setRedirectUri($redirecrUri);
$client->setAccessToken($accessToken);
$url = $client->createAuthUrl();
ajupazhamayil commented 1 year ago

Hi, I see consent does not work. But force and auto are working. Are you still facing this issue?

consent works with $client->setPrompt('consent'); though, lets see if we can edit the documentation page itself (https://developers.google.com/identity/protocols/oauth2/web-server)

bshaffer commented 1 year ago

@anibalsanchez The correct configuration is to use:

$client->setPrompt('consent');

I have tested this using the simple file upload example and adding the line above to line 40, and I received the prompt as expected and did not receive the "Access Blocked: Authorization Error" you reported, so I believe there was something else incorrect in your calling code when you received this error.

I suggest trying again, and making sure you do not include a value for ApprovalPrompt, and that the value for Prompt is "consent".

anibalsanchez commented 1 year ago

Thanks for your feedback. I'm going to re-test the case.

anibalsanchez commented 11 months ago

The same issue remains for all values of the prompt param:

Please, let me know if there's anything I can test.

ajupazhamayil commented 11 months ago

@anibalsanchez Is this the latest you are using?

anibalsanchez commented 11 months ago

I'm testing with google/apiclient v2.14.0

anibalsanchez commented 11 months ago

The library doesn't seem to be the problem. On the server side, it's correctly receiving the parameters and rejecting the prompt values.

ajupazhamayil commented 11 months ago

Interesting, It was working for me! Could you give me steps you followed to reproduce this issue? (Including the code you used if possible)

anibalsanchez commented 11 months ago

It was also working for me in this account. Pls, give me a few days to prepare the code.