0
votes

I Created Client Id and API Key in the Google Developer Console, I given same url in google console and in my config file

This is my url:

https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A81%2Fmoviemuseui%2Fpublic%2Flogin%2FcheckLogin+&client_id=XXXXXXXX-xxxxxxxxxxxxxxxxx.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&access_type=offline&approval_prompt=force

I am getting a error

  1. That’s an error.

Error: invalid_request

Invalid parameter value for redirect_uri: Uri must consist of printable ASCII characters: localhost:81/moviemuseui/public/login/checkLogin

How to solve this, I can't find the problem.

4

4 Answers

2
votes

Your redirect uri must NOT contain space " "

0
votes

Excluded US-ASCII Characters disallowed within the URI syntax:

   control     = <US-ASCII coded characters 00-1F and 7F hexadecimal>
   space       = <US-ASCII coded character 20 hexadecimal>
   delims      = "<" | ">" | "#" | "%" | <">

There are also some characters that may be allowed in URI syntax but can cause problems.

"{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"

And the following characters are absolutely reserved for a query component and they are used for specific meaning in the protocol.

";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ","
0
votes

You don't need to url encode everything. The first call to for authentication just displays a page to your users for them to approve your access. It is a normal HTTP GET you can test it in any webbrowser.

The following works:

https://accounts.google.com/o/oauth2/auth?client_id={clientid}.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/userinfo.email&response_type=code

This one adds your redirect uri, remember redirect uri should point to the page where you would like to handle authentication.

https://accounts.google.com/o/oauth2/auth?client_id={clientid}.apps.googleusercontent.com&redirect_uri=http:// localhost:81/moviemuseui/public/login/checkLogin/Filename.php&scope=https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/userinfo.email&response_type=code

I have a tutorial that explains how the calls should be put together: Google 3 legged oauth2 flow

Question: If you are using the Google-api-php-client why are you building this manually?

Your error Redirect_URI: must match the page where you would like to handle the authentication. For example: http:// localhost/google-api-php-client-samples/oauth2.php It should be set in the developer console, and used in your script.

0
votes

Just check if the URI does not contains any spaces. I too had the same problem and was resolved by deleting the spaces at the end.