如何解决如何将复制Delphi与Google Calendar API集成,如何插入日历?
我正在尝试使用post方法发送请求,该请求方法的内容在正文中,该内容是将包含在API中的日历信息 但是根据请求,它会返回未经授权的401,我不知道将Acces令牌放在Delphi的REST组件中的什么位置,或者我认为对于请求工作很重要的Scopo的位置。 非常感谢您对开发人员的帮助
我的代码
procedure TOAuth2TesterFrm.incluir_btnClick(Sender: TObject);
var
json,token: String;
begin
token:=RefreshTokenEdt.Text;
json:=(
'{"kind": "calendar#calendarListEntry","etag": "0","id": "iago21092020@gmail.com",' +
'"summary": "Calendario Outro","description": "Descrição do evento",' +
'{"date": "2020 August 11","dateTime": "2020-08-11T17:35:36+03:00"}'+
'"timeZone": "Brasília-DF","colorId": "15","backgroundColor": "#9fc6e7","foregroundColor": "#000000",' +
'"selected": true,"accessRole": "owner","primary": true,'+
'"defaultReminders": [{"method": "popup","minutes": 30},{"method": "email","minutes": 10}],' +
'"notificationSettings": {"notifications": [{"method": "email","type": "eventCreation"},' +
'{"method": "email","type": "eventChange"},"type": "eventCancellation"},"type": "eventResponse"}]}}');
try
client.ResetToDefaults;
request.ResetToDefaults;
response.ResetToDefaults;
client.BaseURL:='https://www.googleapis.com/calendar/v3';
response.ContentType := 'application/json';
request.Method := TRESTRequestMethod.rmPOST;
request.Body.ClearBody;
client.AcceptEncoding:='UTF-8';
client.ContentType:='text/html';
request.Resource := 'calendars';
request.Params.AddHeader('Authorization','Bearer '+token);
request.Params.ParameterByName('Authorization').Options := [poDoNotEncode];
request.AddBody(json);
request.Execute;
ShowMessage(request.Response.StatusCode.ToString);
finally
request.Free;
response.Free;
client.Free;
end;
end;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。