Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Delphi在Google日历中创建事件-错误401_Delphi_Google Api_Google Calendar Api_Gdata_Gdata Api - Fatal编程技术网

使用Delphi在Google日历中创建事件-错误401

使用Delphi在Google日历中创建事件-错误401,delphi,google-api,google-calendar-api,gdata,gdata-api,Delphi,Google Api,Google Calendar Api,Gdata,Gdata Api,我的程序必须连接到Google日历并创建一个事件,但我收到一个错误,文本为“令牌无效-AuthSub令牌的作用域错误” 网址是 这是我的代码: Begin createXML := '<?xml version=''1.0'' encoding=''UTF-8''?>'#13#10 + '<entry xmlns=''http://www.w3.org/2005/Atom'''#13#10 + 'xml

我的程序必须连接到Google日历并创建一个事件,但我收到一个错误,文本为“令牌无效-AuthSub令牌的作用域错误”

网址是

这是我的代码:

Begin
  createXML := '<?xml version=''1.0'' encoding=''UTF-8''?>'#13#10 +
                  '<entry xmlns=''http://www.w3.org/2005/Atom'''#13#10 +
                  'xmlns:gd=''http://schemas.google.com/g/2005''>'#13#10 +
                  '<category scheme=''http://schemas.google.com/g/2005#kind'''#13#10 +
                  'term=''http://schemas.google.com/g/2005#event''></category>'#13#10 +
                  '<title type=''text''>' + title + '</title>'#13#10 +
                  '<content type=''text''>' + content + '</content>'#13#10 +
                  '<gd:transparency'#13#10 +
                  'value=''http://schemas.google.com/g/2005#event.opaque''>'#13#10 +
                  '</gd:transparency>'#13#10 +
                  '<gd:eventStatus'#13#10 +
                  'value=''http://schemas.google.com/g/2005#event.confirmed''>'#13#10 +
                  '</gd:eventStatus>'#13#10 +
                  '<gd:where valueString=''' + location + '''></gd:where>'#13#10 +
                  '<gd:when startTime=''' + EventStartTime + ''''#13#10 +
                  'endTime=''' + EventEndTime + '''></gd:when>'#13#10 +
                  '</entry>';

  HTTP:=THTTPSend.Create;
  url:=Edit3.Text;
  WriteStrToStream(HTTP.Document,EncodeURL(createXML));
  HTTP.Headers.Add('Authorization: OAuth '+OAuth.Access_token);
  HTTP.Headers.Add('GData-Version: 2');
  HTTP.MimeType:=('application/atom+xml');
  if HTTP.HTTPMethod('POST',url) then
  XML:=HTTP.Document;
  Memo2.Lines.LoadFromStream(XML);
End;
非常感谢您抽出时间

用户:Google translate

您可以阅读协议,包括它需要什么授权头。即使添加了代码,仍然不清楚OAuth对象是如何构建的


但是,我不建议您继续使用gdataapi,因为它已被弃用。考虑使用基于JSON的V3版本以及新的身份验证方法。API规范和用法也是新的,因此您需要投入一些时间。

如果您添加了与OAuth.Access\u令牌相关的代码,这将非常有用。@AMS添加OAuth Connect的代码,完成。谢谢,目前我正在使用ClientLogin方法,但很快就会进入OAuth 2.0
 Const
    client_id=%s&client_secret=%s&code=%s&redirect_uri=%s&grant_type=authorization_‌​‌​code'; 

.....

        procedure TForm2.Button4Click(Sender: TObject); var HTTP:THTTPSend; 
        begin HTTP:=THTTPSend.Create; 
        try 
        HTTP.Headers.Add('Authorization: OAuth '+OAuth.Access_token); 
        HTTP.Headers.Add('GData-Version: 2'); 
        if       HTTP.HTTPMethod('GET','google.com:443/calendar/feeds/default/allcalendars/full') then 
        XML:=HTTP.Document; 
        End;