2016-05-12 48 views
0

我已經繼承了一個谷歌AdWords項目,該項目使用OAuth 2.0安裝的應用程序連接到谷歌AdWords API。Google Adwords OAuth「error」:「invalid_client」異常

我倒在第一關;我從github下載了下面的示例項目;

https://github.com/googleads/googleads-dotnet-lib/tree/master/examples/AdWords/CSharp/OAuth

當我把所有的細節到web.config中的指示它不工作。 我已經放入;

  • 開發人員令牌
  • 客戶ID
  • 刷新令牌。

這對我來說是全新的,我的理解是,當使用刷新令牌時,應用程序應該獲得一個新的訪問令牌並允許訪問該API。

screengrab of the sample app

上述圖像顯示示例應用程序接口,當我點擊「獲取的廣告活動」鏈接收到異常消息;

Google.Api.Ads.Common.Lib.AdsOAuthException was caught 
    HResult=-2146233088 
    Message=Failed to refresh access token. 
{ 
    "error" : "invalid_client" 
} 
    Source=Google.Ads.Common 
    StackTrace: 
     at Google.Api.Ads.Common.Lib.OAuth2ProviderForApplications.RefreshAccessTokenInOfflineMode() 
     at Google.Api.Ads.Common.Lib.OAuth2ProviderForApplications.RefreshAccessToken() 
     at Google.Api.Ads.Common.Lib.OAuth2ProviderBase.RefreshAccessTokenIfExpiring() 
     at Google.Api.Ads.Common.Lib.OAuth2ProviderForApplications.RefreshAccessTokenIfExpiring() 
     at Google.Api.Ads.Common.Lib.OAuth2ProviderBase.GetAuthHeader() 
     at Google.Api.Ads.Common.Lib.OAuth2ProviderForApplications.GetAuthHeader() 
     at Google.Api.Ads.AdWords.Lib.AdWordsSoapClient.InitForCall(String methodName, Object[] parameters) 
     at Google.Api.Ads.Common.Lib.AdsSoapClient.MakeApiCall(String methodName, Object[] parameters) 
     at Google.Api.Ads.Common.Lib.AdsSoapClient.Invoke(String methodName, Object[] parameters) 
     at Google.Api.Ads.AdWords.v201601.CampaignService.get(Selector serviceSelector) 
     at Google.Api.Ads.AdWords.Examples.CSharp.OAuth.Default.OnGetCampaignsButtonClick(Object sender, EventArgs eventArgs) in c:\Adwords\examples\AdWords\CSharp\OAuth\Default.aspx.cs:line 130 
    InnerException: 

該應用程序在以前的應用程序中使用這些證書,似乎沒有問題。

我已經搜索了高和低的答案,例外說,訪問令牌無法刷新,但模棱兩可的推理並沒有幫助很大。

有人可以提供任何進一步的見解嗎?

非常感謝。

回答

0

您應該在webconfig中設置OAuth2ClientId和OAuth2ClientSecret值。

<add key="OAuth2ClientId" value="your client id"/> 
<add key="OAuth2ClientSecret" value="your client secret"/> 

您可以從 https://console.developers.google.com/project

獲得客戶端ID和客戶端密碼提供的OAuth2用戶端ID和密碼。您可以從 https://console.developers.google.com/project創建一個。請參閱 https://developers.google.com/identity/protocols/OAuth2WebServer 瞭解更多詳情。

相關問題