2012-12-31 190 views
0

我已经在我的网站上实现了几个谷歌API - 以禁止联系人导入和YouTube上传。当在本地(在我自己的开发服务器的本地主机下)一切正常工作时,使用它们通过站点(HostGator和1and1托管,我在任何地方都收到相同的错误)有一些问题 - 似乎是 身份验证问题。ASP.NET网站授权问题与谷歌和YouTube的API

该网站是在ASP.NET 2.0,这些都是错误的MSG我得到:

  1. 错误的谷歌联系人(使用AuthSub) - 这种情况发生后,我顺利地收到来自谷歌的的AuthSub会话令牌:

    The remote server returned an error: (401) Unauthorized. 
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information 
    
    about the error and where it originated in the code. 
    
    Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized. 
    
    Source Error: 
    
    
    Line 493:  ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default")); 
    Line 494: 
    Line 495:  ContactsFeed feed = service.Query(query); 
    Line 496: 
    Line 497:  ArrayList emails = new ArrayList(); 
    
    Source File: d:\inetpub\vhosts\e-koren.com\httpdocs\home-cooking\EmailInvite.aspx.cs Line: 495 
    
  2. 错误为(是使用ClientLogin)的YouTube视频上传:

    Invalid credentials 
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information 
    
    about the error and where it originated in the code. 
    
    Exception Details: Google.GData.Client.InvalidCredentialsException: Invalid credentials 
    
    Source Error: 
    
    
    Line 71: //   try 
    Line 72: //   { 
    Line 73:     FormUploadToken _token = request.CreateFormUploadToken(newVideo); 
    Line 74: 
    Line 75:     actionURL.Value = _token.Url + "?nexturl=" + Server.UrlPathEncode(Request.Url.ToString()+"?uuc="); 
    
    Source File: d:\inetpub\vhosts\e-koren.com\httpdocs\home-cooking\youtubeUpload.aspx.cs Line: 73 
    

任何人都知道它会是什么?

感谢, 阿萨夫

回答

0

我设法最终解决售后服务它:

作为第一个错误(的AuthSub和谷歌联系人) - 我从 “HTTP” 为 “https” 改变了URI:

// V1 
GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory("cp",gn.ytApplicationName); 

authFactory.Token = (String)Session["token"]; 

ContactsService service = new ContactsService(authFactory.ApplicationName); 

service.RequestFactory = authFactory; 

ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default")); 

// VERY IMPORTANT! adding HTTPS resolves google's bug (401 error) 
query.Uri = new Uri("https://www.google.com/m8/feeds/contacts/default/full"); 

ContactsFeed feed = service.Query(query); 

关于第二个错误(ClientLogin的) - appearantly谷歌已经收紧围绕这种方法的安全性措施 - 他们发送警告电子邮件,我想通过登录用户 - 只有当他如下几个复杂的步骤他们授权访问他的视频。

因为我发现这不是一个错误,而是一个政策,我想我也只是在那里切换到AuthSub。

希望我能帮助别人太...

:)