403 Forbidden error message when accessing Adwords API

281 views
Skip to first unread message

mick....@bbconsult.co.uk

unread,
Jan 8, 2014, 8:58:26 AM1/8/14
to adwor...@googlegroups.com, Dhruves...@bbconsult.co.uk

Hello,


I’m wondering if you can help.


We have access to the Google Adwords Developer API access token approved, and downloaded a sample .NET console application code from Adwords API web page in Feb 2013 – which worked fine then. 

 

When we tried to test it again now, we discovered '403 forbidden' error message (see copy of error details below for full error details).


Our current code does not go as far as attempting to retrieve campaigns, for the moment it is just trying to pass authentication with OAuth using the developer token - which it is failing at.

 

The below is the error log information from the latest version:

 

This code example lists all campaigns. To add a campaign, run AddCampaign.cs.


An exception occurred while running this code example.

 

System.Reflection.TargetInvocationException (Exception has been thrown by the target of an invocation.)

   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)

   at Google.Api.Ads.AdWords.Examples.CSharp.Program.InvokeRun(Object codeExample, AdWordsUser user) in C:\Dev\QuickWins\Google Adwords\awapi_dotnet_lib_v15.8.0\examples\CSharp\Program.cs:line 178
   at Google.Api.Ads.AdWords.Examples.CSharp.Program.RunACodeExample(AdWordsUser user, Object codeExample) in C:\Dev\QuickWins\Google Adwords\awapi_dotnet_lib_v15.8.0\examples\CSharp\Program.cs:line 130

Caused by

System.ApplicationException (Failed to retrieve campaigns)

   at Google.Api.Ads.AdWords.Examples.CSharp.v201302.GetCampaigns.Run(AdWordsUser user) in C:\Dev\QuickWins\Google Adwords\awapi_dotnet_lib_v15.8.0\examples\CSharp\v201302\BasicOperations\GetCampaigns.cs:line 100

Caused by

Google.Api.Ads.Common.Lib.AuthTokenException (AuthToken login failed. See ErrorCode for more details.)

   at Google.Api.Ads.Common.Lib.AuthToken.GenerateToken() in c:\src\MyProjects\now\Common library base\adwords\compile\Lib\AuthToken.cs:line 247
   at Google.Api.Ads.Common.Lib.AuthToken.GetToken() in c:\src\MyProjects\now\Common library base\adwords\compile\Lib\AuthToken.cs:line 192
   at Google.Api.Ads.AdWords.Lib.AdWordsSoapClient.InitForCall(String methodName, Object[] parameters) in c:\src\MyProjects\now\Common library base\adwords\compile\Lib\AdWordsSoapClient.cs:line 66
   at Google.Api.Ads.Common.Lib.AdsSoapClient.MakeApiCall(String methodName, Object[] parameters) in c:\src\MyProjects\now\Common library base\adwords\compile\Lib\AdsSoapClient.cs:line 211
   at Google.Api.Ads.Common.Lib.AdsSoapClient.Invoke(String methodName, Object[] parameters) in c:\src\MyProjects\now\Common library base\adwords\compile\Lib\AdsSoapClient.cs:line 127
   at Google.Api.Ads.AdWords.v201302.CampaignService.get(Selector serviceSelector) in c:\src\MyProjects\now\Common library base\adwords\compile\v201302\AdWordsApi.cs:line 4949
   at Google.Api.Ads.AdWords.Examples.CSharp.v201302.GetCampaigns.Run(AdWordsUser user) in C:\Dev\QuickWins\Google Adwords\awapi_dotnet_lib_v15.8.0\examples\CSharp\v201302\BasicOperations\GetCampaigns.cs:line 83

Caused by

System.Net.WebException (The remote server returned an error: (403) Forbidden.)

   at System.Net.HttpWebRequest.GetResponse()
   at Google.Api.Ads.Common.Lib.AuthToken.GenerateToken() in c:\src\MyProjects\now\Common library base\adwords\compile\Lib\AuthToken.cs:line 232

 

We implemented catching AuthTokenException in the stack trace.

Its ErrorCode field value is BadAuthentication

Any suggestions/help is much appreciated.

config file - MASKED PASSWORDS.config

Ray Tsang (AdWords API Team)

unread,
Jan 13, 2014, 3:09:50 PM1/13/14
to adwor...@googlegroups.com, Dhruves...@bbconsult.co.uk
Mick,

It sounds like you have determined that the ErrorCode field value is BadAuthentication.  According to the ClientLogin documentation, BadAuthentication indicates that the username and password is not recognized.  Please verify the username/password.

On the other note, ClientLogin usage is deprecated and will sunset in June 2014.  Please use OAuth 2.0 with the AdWords API instead.

Cheers,

--
Ray Tsang (AdWords API Advisor)
Reply all
Reply to author
Forward
0 new messages