Tag: 未经授权

为什么我在Google Calendar API中收到(401)未经授权的错误

我一直在使用谷歌日历API,并陷入困境。 当我在下面调用它来删除日历事件时,它在第一遍和第二阶段正常工作。 但是,在第二次或第三次我称这种方法时,我得到(401)未经授权的错误 。 它每次都使用相同的凭据。 如果我得到exception,我可以重置 catch中的凭据 ,它可以正常工作。 我宁愿不要这样做。 有任何想法吗? CalendarService myService = new CalendarService(“mycompany-myapp-1”); myService.setUserCredentials(“jo@username.com”, “password”); // set the query for the event EventQuery myQuery = new EventQuery((“http://www.google.com/calendar/feeds/jo@username.com/private/full”)); myQuery.Query = “Cut the grass”; myQuery.StartTime = DateTime.Now; myQuery.EndTime = DateTime.Now.AddDays(1); // find the event EventFeed myResultsFeed = null; try { // execute the query to […]

Exchange Web Service API和401未经授权的例外

当我尝试使用EWS API发送电子邮件时,我收到以下错误:(在message.Send(); ) 请求失败。 远程服务器返回错误:(401)未经授权。 我的代码如下: ExchangeService exchangeService = new ExchangeService(ExchangeVersion.Exchange2007_SP1); //WebService Uri try { exchangeService.Url = new Uri(“https://exchangeserver/ews/exchange.asmx”); } catch (Exception ex) { throw new Exception(string.Format(“WebService Uri:” + ex)); } //Credentials try { exchangeService.Credentials = new WebCredentials(“user@domain”, “pwd”, “domain”); } catch (Exception ex) { throw new Exception(string.Format(“Credentials:” + ex)); } //Send a mail try […]

如何使用C#安装Windows字体

如何使用C#安装字体? 我尝试使用File.Copy()复制字体但由于访问权限限制( UnauthorizedException ),我不被允许。 我该怎么办?