简体   繁体   中英

Why am I still getting invalid_client error?

I am working on a Google Drive API tutorial

I am currently on the part where you run the demo. When I visit the URL generated by the program, I get this error - "Error: invalid_client . The OAuth client was not found."

Here is my code(subbed in my client_id and client_secret)

 public class DriveCommandLine {

  private static String CLIENT_ID = "37895131772";
  private static String CLIENT_SECRET = "laUVGRI53uXzT90Ag880HSkT";
  private static String REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob";
 ....

I double checked the client_id and client_secret on the Developer's console to make sure those components were not the issue.(tutorial didn't say to replace redirect_uri)

Does anyone know what the issue is? I checked this thread as well and the solution there was to set email and product name to the same name as the Eclipse project. I did both(my email and DriveTutorial, name of Eclipse project) but still I got the same error.

Are you using the correct client ID (sorry for asking but read below)?

I just generated one and it looks like this: 826972360704-pc2l8e4bvvg7e4a64nen8ofdsk41c60p.apps.googleusercontent.com Your client ID looks like it is just the first numbers before the dash (unless you obfuscated it which is usually not needed since client id is considered public information)

Also I tried calling following URL:

https://accounts.google.com/o/oauth2/auth?access_type=online&approval_prompt=auto&client_id=897110948812-7nhm1mqpb8dekoalbl6go7appruttn01.apps.googleusercontent.com&redirect_uri=https://www.example.com/oauth2callback&response_type=code&scope=https://www.googleapis.com/auth/drive

And correctly got the OAuth "grant permission to application X" prompt.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM