没有库的Google Calendar API示例

Jam*_*mes 7 java authentication http google-calendar-api

我正在寻找一个使用HTTP GET或POST使用Google Calendar API的简单示例

所有这些例子都需要这些用于语言X的巨大库.我只想要一个原始的http示例,该示例可以在任何语言中使用,并且不需要库.

https://www.googleapis.com/calendar/v3/users/me/calendarList/primary?key=mykey

但当然这不起作用,我认为您的Google API密钥没有关键选项,您需要以某种方式对其进行授权.

Java或JavaScript中的原始示例是理想的,

就像是,

HttpPost request = new HttpPost("https://www.googleapis.com/calendar/v3/users/me/calendarList/primary?key=mykey");
DefaultHttpClient client = new DefaultHttpClient();
client.getCredentialsProvider().setCredentials(
new AuthScope(AuthScope.ANY),
new UsernamePasswordCredentials(user, password));
HttpResponse response = client.execute(request);
Run Code Online (Sandbox Code Playgroud)

但.. ..有效,什么是用户/密码或如何验证Auth ...

任何帮助都非常感谢.

Jam*_*mes 5

这篇文章回答了这个问题.

答案帖子引用了how2,它告诉你如何使用HTTP GET/POST在三个简单的步骤中调用任何google auth API,而不需要任何客户端库.

我花了一天时间尝试使用Google的how2s和客户端库来完成某些工作,并且没有最终得到任何我可以使用的东西.但是遵循这个how2,我在我的应用程序中得到了它的工作时间.非常感谢博主.

使用Apache HttpClient调用Google auth API