Getting invalid_client error data

14,990 views
Skip to first unread message

Xinyue Zhai (翟欣玥)

unread,
Sep 6, 2011, 1:25:53 AM9/6/11
to gtm-oauth2
Hi,

I downloaded the sample code and wanted to learn and play with it. I followed the introduction to registered my app on the API console as Doraemon and got the client ID and secret key.

I run the OAuthSampleTouch in the iphone simulator, and typed the client ID and secret key in the text fields. It successfully redirects to the google login screen.  I use my company email and personal email to login and allow the permission for the app to access data. Everything seems work well. But when the web view closed, it returns a error message to the finishedSelector as below:

2011-09-06 13:11:36.238 OAuthSampleTouch[12454:40b] Error Error Domain=com.google.HTTPStatus Code=400 "The operation couldn’t be completed. (com.google.HTTPStatus error 400.)"

Error data:

{

    error = "invalid_client";

}

I have double checked that this error data means invalid client identifier. Do I miss something on applying for the client ID?
I am new to OAuth. Please help me on this issue or point to some related documentation to resolve this problem.

Thanks a lot!


--
Best Wishes!
Xinyue Zhai(翟欣玥)
Seat 322C, Ext 3627
 
Software Engineer
Infrastructure Networking Department
Google China

Sumit Maitra

unread,
Sep 6, 2011, 3:40:18 AM9/6/11
to gtm-o...@googlegroups.com
Hi,
Did you register your app as a web app or client app? I had made that mistake first time around.

Thanks and Regards,
Sumit.

Xinyue Zhai (翟欣玥)

unread,
Sep 6, 2011, 3:44:58 AM9/6/11
to gtm-o...@googlegroups.com
Hi Sumit,

I registered my app as installed application. And how did you resolve the similar issue?

Sumit Maitra

unread,
Sep 6, 2011, 3:54:37 AM9/6/11
to gtm-o...@googlegroups.com
Hello Xinyue,

Since I had made the mistake of registering my app as web client instead of installed client, I was getting this error. One i got the client id and key for installed app, things worked. But you seem to be on the right track so we'll have to wait for Greg to help out here.

I will look up my thread too to see if I can find something.

Regards,
Sumit.

Sumit Maitra

unread,
Sep 6, 2011, 4:07:19 AM9/6/11
to gtm-o...@googlegroups.com
Hello Xinyue,

I must apologize, I was getting 400 - redirect_uri_mismatch and not invalid client ID. Please disregard my earlier comments. One thing that might help is, which Service API did you register the app for?

Thanks and Regards,
Sumit.

Xinyue Zhai (翟欣玥)

unread,
Sep 6, 2011, 4:13:38 AM9/6/11
to gtm-o...@googlegroups.com
Hi Sumit,

I just register buzz api for test, and the scope defined in the code is 

      NSString *scope = @"https://www.googleapis.com/auth/buzz";

Thanks

Xinyue Zhai (翟欣玥)

unread,
Sep 7, 2011, 5:59:01 AM9/7/11
to gtm-o...@googlegroups.com
Hi,

I found this issue very interesting.
Today I debug the whole sample code, and find that the app can successfully get the authorization code. But when using fetcher to get the access code, it receives the invalid_client error message. So I guess there must be something wrong with the client id. Then I register a test project and get new client id and client secret. Everything works well. The procedure for applying client id for the two projects are the same, but I don't know why the results are a little different.

Thanks.

Chris Lacy

unread,
Oct 12, 2011, 1:42:47 AM10/12/11
to gtm-o...@googlegroups.com
I just experienced this issue. My advice: triple check your Client ID/Secret are correct. In my case, I was mistaking a 'l' (the letter L) in the secret for a '1' (the number 1).

Nguyen Dinh Hung

unread,
Oct 24, 2013, 9:58:47 AM10/24/13
to gtm-o...@googlegroups.com, scot.s...@icix-usa.com


On Thursday, October 4, 2012 11:03:43 AM UTC+7, Scot Stennis wrote:
I know I'm "late to the party", but I ran into this issue today while trying to get the GTM OAuth2 lib calls to work. I triple checked my IDs, etc., but everything was correct. I found the solution to my issue was in the GTM OAuth2 introduction web page (http://code.google.com/p/gtm-oauth2/wiki/Introduction), which stated:

"In the console, create a project, then click "API Access" in the left column. Create a new Client ID for an Installed Application (not a web application) type other (not iOS)."

I had registered my app as an "iOS" installed app, and when I changed it to "other", everything worked.

Hope that helps someone else too.

On Tuesday, October 11, 2011 10:42:47 PM UTC-7, Chris Lacy wrote:
I just experienced this issue. My advice: triple check your Client ID/Secret are correct. In my case, I was mistaking a 'l' (the letter L) in the secret for a '1' (the number 1).


I changed it to "other" but error is " Error Domain=com.google.GTMOAuth2 Code=-1001" . Why? What do i fix?
Reply all
Reply to author
Forward
0 new messages