I'm looking for a very simple example of using the Google Calendar API using HTTP GET or POST
All there examples require these huge libraries for language X. I just want a raw http example that would work in any language and require no libraries.
i.e. https://www.googleapis.com/calendar/v3/users/me/calendarList/primary?key=mykey
But of course this does not work, I don't think there is a key option for your Google API key, and you need to authorize it somehow.
A raw example in Java or JavaScript would be ideal,
Something like,
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);
But.. that works, and what are user/password or how to validate Auth...
Any help is vastly appreciated.
This question was answered in this post.
The answer post references a how2 that shows you how to call any google auth API in three simple steps using just HTTP GET/POST and not requiring any client libraries.
I spent over a day trying to get something working using Google's how2s and client libraries, and did not end up with anything I could use. But following this how2, I got it working in under and hour in my app. Thanks a lot to the blogger.
call Google auth API using Apache HttpClient
You might want to check the JavaScript Quickstart or Java Quickstart for a simple sample. Upon checking the Authorizing Requests to the Google Calendar API document, it stated that:
Every request your application sends to the Google Calendar API must include an authorization token. The token also identifies your application to Google.
Your application must use OAuth 2.0 to authorize requests. No other authorization protocols are supported. If your application uses Google Sign-In, some aspects of authorization are handled for you.
Also, if you want to have a very concrete sample of Google Calendar API using HTTP GET or POST, you can use the Try it! which you can see in each API Reference. Note that, there is an authorize and execute button (OAuth 2.0).
Tip: The Google APIs client libraries can handle some of the authorization process for you. They are available for a variety of programming languages; check the page with libraries and samples for more details.
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With