[英]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
一起工作的示例代码。
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: 要总结本文,请转到:
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.