简体   繁体   English

Google Content API for Shopping-凭据在本地可以正常使用,但不能在实时服务器上使用

[英]Google Content API for Shopping - Credentials work fine locally but not on live server

I have taken the sample code from: 我从以下示例代码:

https://developers.google.com/shopping-content/developers-guide-dotnet https://developers.google.com/shopping-content/developers-guide-dotnet

ContentForShoppingService service = 
    new ContentForShoppingService("ContentForShopping-Sample");
service.setUserCredentials(GoogleUsername, GooglePassword);

service.AccountId = GoogleAccountID;

I also used sample code from https://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/contentforshopping_sample/contentforshoppingsample.cs?r=1067 我还使用了https://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/contentforshopping_sample/contentforshoppingsample.cs?r=1067的示例代码

I am using the Google Merchant email address/password and the Merchant ID for the above. 我在上面使用Google Merchant电子邮件地址/密码和Merchant ID。 I then locate one of our products using: 然后,我使用以下方法找到我们的一种产品:

entry = service.Get("en", "gb", ProductID);

This works fine on my local server. 这在我的本地服务器上工作正常。 I can then update the product by manipulating its properties, and then calling: 然后,我可以通过操纵产品的属性来更新产品,然后调用:

service.Update(entry);

Now, the problem is that when I run this on our live server it fails with: 现在的问题是,当我在实时服务器上运行它时,它失败并显示:

Exception Details: 
    Google.GData.Client.InvalidCredentialsException: Invalid credentials

What are the reasons for the same credentials working on one PC and not on another? 同一凭据在一台PC上而不在另一台PC上工作的原因是什么?

Should I be using another method to submit my credentials? 我应该使用其他方法提交我的凭据吗? I found the alternative methods bewildering and I could find no other sample code that works specifically with ContentForShoppingService . 我发现其他方法令人困惑,并且找不到其他专门与ContentForShoppingService一起工作的示例代码。

  • The local PC is running Windows 7 本地PC正在运行Windows 7
  • The problematic live server is running Windows Server 2008 R2 有问题的实时服务器正在运行Windows Server 2008 R2

Update 更新资料

I have taken the same code and put it inside a Windows Form Application. 我已经将相同的代码放入Windows窗体应用程序中。 This application runs fine on all other machines I've tried it on, except for the live servers that we use. 除了我们使用的实时服务器外,该应用程序在我尝试过的所有其他计算机上均可正常运行。 This would make me think that this is a security software/firewall issue of some kind... 这会让我认为这是某种安全软件/防火墙问题。

Any ideas?! 有任何想法吗?!

I had exact same issue, i solved it by enabling 2-step Verification. 我遇到了完全相同的问题,我通过启用两步验证解决了该问题。 mentioned in the article here 文章中提到这里

To summarize this article, goto: 要总结本文,请转到:

  1. https://support.google.com/accounts/answer/180744 https://support.google.com/accounts/answer/180744
  2. enable 2 step verification 启用两步验证
  3. enter your information 输入您的信息
  4. enter your app name 输入您的应用名称
  5. generate your app password 生成您的应用密码
  6. replace in your password in your code 在代码中替换密码

Good luck :) 祝好运 :)

The issue with this was solved by going to: 此问题已通过以下方法解决:

https://security.google.com/settings/security/activity?hl=en_GB https://security.google.com/settings/security/activity?hl=zh_CN

It appears that Google tries to learn which IP addresses are OK for your app. Google似乎试图了解哪些IP地址适合您的应用。 Despite me saying that the prevented addresses were fine, they were still being blocked. 尽管我说被阻止的地址很好,但它们仍然被阻止。

在此处输入图片说明

The solution was to go to the live server, open a browser on there and then sign in to the Google account on there. 解决方案是转到实时服务器,在该服务器上打开浏览器,然后登录该服务器上的Google帐户。 Since you're signing in physically at that IP address, Google then knows that this address is not suspicious. 由于您实际上是使用该IP地址登录的,因此Google知道此地址不是可疑的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Map Direction Api在本地工作正常,但在服务器上部署后无法正常工作 - Google Map Direction Api Works Fine Locally but does not work properly when deployed on Server Google Calendar Api在本地运行良好,但未在服务器上提高其身份验证 - Google Calendar Api working fine Locally but not raising its Authentication on Server 本地保存的凭据 google drive api 3 - Locally saved credentials google drive api 3 代码在本地运行良好,但在GoDaddy上实时发布时出错 - Code running fine locally but erroring when published live on GoDaddy TLS在服务器盒中失败,但在本地工作正常 - TLS fails in server box but works fine locally 更新查询在本地工作正常,但在远程服务器上不行 - Update Query works fine locally but not on Remote server Pushsharp:IOS通知在本地运行,但不在实时服务器上运行 - Pushsharp: IOS notifications are working locally but not on live server 如何在Google Shopping中使用API​​ KEY - How to use the API KEY in google shopping 内容类型为“ application / x-www-form-urlencoded”的POST请求在服务器(QA,UAT…)中不起作用,但在本地运行良好 - POST Request with content type “application/x-www-form-urlencoded” is not working in server(QA,UAT…) but works fine locally 部署到服务器后,无法在C#Ajax应用程序中下载文件。 在本地运行很好,没有问题 - Downloading a file in a C# Ajax application does not work when deployed to server. Running locally is fine and has no issues
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM