Migration from clientLogin to oAuth2

135 views
Skip to first unread message

Shruti

unread,
Oct 17, 2014, 3:55:23 PM10/17/14
to adwor...@googlegroups.com
Hi,

I'm trying to migrate an application from using ClientLogin to oAuth2. I have followed the instructions as given here - https://developers.google.com/adwords/api/docs/guides/clientlogin-to-oauth2-single-mcc and https://developers.google.com/adwords/api/docs/guides/authentication

As indicated, I have
1. created a new project in the developer console.
2. added credentials for installed application and generated the clientId and client secret.
3. set up the consent form with email and the product name
4. used the client library utility to generate the authorization code
5. Copied the authorization code back to the client library utility to exchange it for access token and the refresh token (which resulted in invalid client)

6. So, I finally I used the oauth playground (note - I used the sandbox scope) to get the access token and refresh token and used these in my application config.

But still get the below error -

{"Failed to refresh access token.\n{\n  \"error\" : \"unauthorized_client\"\n}"}

I find all this process just to obtain the authorization to access my older adwords account too frustrating. Can you please help me identify if I'm missing anything here?

Any urgent help will be appreciated.

Thanks.

Shruti

unread,
Oct 17, 2014, 4:34:37 PM10/17/14
to adwor...@googlegroups.com
NoRefreshToken.JPG

Josh Radcliff (AdWords API Team)

unread,
Oct 18, 2014, 8:58:52 AM10/18/14
to adwor...@googlegroups.com
Hi,

Sorry to hear this process has been frustrating for you. Have you looked at the step-by-step instructions for OAuth2 on the .NET library's wiki pages?


The invalid_client message you received in step 5 usually means that the client ID or client secret are incorrect. If that's not the issue and the step-by-step instructions don't help, please post a reply here. Note that if you need to send any sensitive information along to me for troubleshooting you can do so by clicking the Reply to Author option.

Thanks,
Josh, AdWords API Team


On Friday, October 17, 2014 3:55:23 PM UTC-4, Shruti wrote:

Shruti

unread,
Oct 20, 2014, 11:16:19 AM10/20/14
to adwor...@googlegroups.com
Hi Josh,

Thanks for the reply. I have gone through the step by step instructions for generating the refresh token.

I'm using the OAuthTokenGenerator.exe, entering my clientID and the client secret after which I can see the consent screen.
Once I click the 'Accept'  button, I see a screen showing RavenDB documents which are empty. (Please see screen shot in my previous post).

Not sure if I am missing something or if the exe is not working as expected.

Thanks.

Josh Radcliff (AdWords API Team)

unread,
Oct 20, 2014, 12:50:08 PM10/20/14
to adwor...@googlegroups.com
Hi,

I see - I think the problem is that the project you created in the Developers Console is a Web application, but OAuthTokenGenerator.exe assumes you have a Native application. If you create a Native application as described here and use that application's client ID and client secret, then the generator should work as expected.

As an aside, what's happening right now with your Web application is that after you authorize, the OAuth server is redirecting you to your Web application's redirect URL. See the OAuth Web application flow for details.

Cheers,
Josh, AdWords API Team

Shruti

unread,
Oct 20, 2014, 1:09:09 PM10/20/14
to adwor...@googlegroups.com
Hi,

I have created the client ID for the native application (same as installed application, I believe).
I have been following the steps shown on - https://www.youtube.com/watch?v=WifY2fFyaMw for the native application.

Thanks

Josh Radcliff (AdWords API Team)

unread,
Oct 20, 2014, 2:05:08 PM10/20/14
to adwor...@googlegroups.com
Hi,

Could you send a screenshot of your application setup from the Developers Console only to me by clicking Reply to Author?

Thanks,
Josh, AdWords API Team

Derek Gray

unread,
Mar 25, 2015, 11:11:34 AM3/25/15
to adwor...@googlegroups.com
I am experiencing the exact same problem and I can't figure out where I'm going wrong. Should I send over my source code? 

Josh Radcliff (AdWords API Team)

unread,
Mar 25, 2015, 11:28:30 AM3/25/15
to adwor...@googlegroups.com
Hi,

Did you confirm that you are creating a native/installed application in the cloud console?

Also, have you gone through the OAuth wiki page for the client library you are using? That page will contain step-by-step instructions for configuring the library for OAuth.

Thanks,
Josh, AdWords API Team

Anash P. Oommen (AdWords API Team)

unread,
Mar 26, 2015, 4:07:23 PM3/26/15
to adwor...@googlegroups.com
Hi Derek, Shruti,

From an older thread, it looks like the error you mentioned happens when the clientId in your App.config doesn't match the one for which your refreshToken was generated. Could you please check if the values being loaded at runtime matches what you generated using OAuthTokenGenerator? You can do that by adding a debug watch on the expression (AdWordsUser.Config as AdWordsAppConfig).

Cheers,
Anash P. Oommen,
AdWords API Advisor.
Reply all
Reply to author
Forward
0 new messages