GET request to the Google calendar API - javascript

Is it possible to make a GET request to the Google calendar API?
I am using AngularJS to create GET request. But it is not important for me how I will send a GET request(with jQuery, Angular etc.). I am interesting in response.
test.controller('TestCtrl', function ($scope, $http) {
$scope.title="I WANT TO MAKE A REQUEST";
$http.get('https://www.googleapis.com/calendar/v3/calendars/'{{calendarid}}'/events?key='{{apiKey}}').success(function(data){
$scope.tests= data;
});
here is a screenshot of my variables calendarid and apiKey values
Maybe I am doing something wrong? Or you can suggest something? Any answer will be appreciated!
P.S. Please say if you need more details.

Since you a user's calendar, you will need to authenticate with either an OAuth Client or a service account (i.e. a robot user) rather than an API key. The OAuth Client ID that you pointed out is different from the calendar ID. The easiest way to find the calendar ID is to make a calendar list call.
I recommend checking out this getting started guide on how to use the Google API JavaScript library to look up calendar data.

Related

error when I try to fetch calendar events through google API, JS React

For some reason; I get error when trying to get my calendar events through google API. I code in JS and use React and have no idea why it does not work.
I have the token stored in sessionStorage and do get personal information about the user like name email and such stuff but I cannot proceed and get the calendar events. Please help!
I'm not sure what exactly you would like to see inside my App but let me know and I'll provide with the stuff because I do not want to upload the whole project lol
https://gyazo.com/37433e19f07e441adf368d1bbcad78e6
Maybe try to return res.send as you use async/await and it returns promise
I changed the structure of the app and I do now receive cal events when I hit one of my endpoints, but receiving other kind of error now, anyway this one can be closed.
Cross-origin request blocked, origin 'null' no access

How to make Google Calendar API Requests using javascript and a service account?

I followed this quickstart tutorial for the Google Calendar API using javascript in my web application. As I need the possibility to show Calendar data on the webpage without user login, I need to implement API calls using a Service Account. Unfortunately I cant't find any good tutorials or explanations for doing so in javascript and since I am fairly new to the subject of API programming I kind of need some guidance.
Ty in advance.
Using Service account on client side is not secure. You may want to switch to a server side implementation for that. Assuming you are familiar with javascript I suggest to follow NodeJS implementation from here.
To create Service Account select service account after step 1->a.
Refer this image for option.
To use Service Account replace the authorize() logic with this
var email = credentials.client_email;
var key = credentials.private_key;
const jwt = new google.auth.JWT(
email, null, key, SCOPES
);
jwt.authorize((err, data) => {
if (err) {
console.error(err);
throw err;
}
console.log('You have been successfully authenticated: ', data);
callback(jwt);
});
As you are using Service Account you also need to create a calendar in your Gmail account to use. Then go to settings and select Add People to share it with client_email from your json, then use your Calendar Id (from Calendar settings) in API Call replacing primary

Twitter JS API, update status

I'm at a total loss here. I believe I'm right in thinking there is no longer any JS API for twitter which just sucks hugely.
However I realise looking at this I could just use ajax and react to the responses from this:
https://dev.twitter.com/rest/reference/post/statuses/update
OAuth Signature Generator
Example Request POST
https://api.twitter.com/1.1/statuses/update.json?status=Maybe%20he%27ll%20finally%20find%20his%20keys.%20%23peterfalk
However when I post to that url I get the following:
{"errors":[{"code":215,"message":"Bad Authentication data."}]}
Bad Authentication data -> this is very self explanatory: Your Authentication is Bad; in other word, you are not authorized to use that API method.
Since you use POST method, make sure you set your APP access level to Read & Write.
Sign in to apps.twitter.com, and in the Applications Management page for your app, click the Permissions tab. There you can change your access level.
For further reading, please see this answer.

Find location of tower using google geolocation api

I am trying to find the location of cell towers using MNC, MCC, lac and CellID.
I have tried many api's such as opencell, combian etc. But none of them are free.
Is there any rest free API available, but for the moment I am using Google geolocation api.
I am sending request in javascript like this
https://www.googleapis.com/geolocation/v1/geolocate?key=xxx&homeMobileNetworkCode=410&homeMobileCountryCode=310&locationAreaCode=415&cellId=42&format=json
and all the time it return "Not Found"
I checked many places on stackover, but could not find good solution or hint. In addition is there any Free Api Available for getting operator name by using data mnc, mcc, cellid and lac.
In addition, I have also tried to use this link to get location but I could not as I can not find what parameter I need to pass and what should be the url I need to create.
Please provide me some guidelines to get location and operator name for specific tower by using information such as mnc, mcc etc.
Thanks appreciated
Google describes the geolocate API endpoint in their docs. You tried to do a GET request, but they say that you should use POST, with JSON-Formatted data:
Communication is done over HTTPS using POST. Both request and response are formatted as JSON, and the content type of both is application/json.
If you want to use the undocumented API from your link, the URL is http://www.google.com/glm/mmap and the POST-data is what is written in the function WriteData. See the Java Docs for DataOutputStream if you are unfamiliar with the output produced by the various write..-methods.
As for getting the operator name, there are free databases available for that (alternative 1, alternative 2; search google for more, there are plenty).

Use oauth2 to retrieve Google Places client_id

Is it possible to retrieve the Google Places client_id using oauth2? I am able to retrieve Google+ information including the id and Google+ profile url, but I need a way to tie the oauth2 user to the Google Places "client_id".
I have been able to include the Places scope which is listed in the oauth2 popup and asks the user for permission to access the resources, but cannot figure out how to retrieve the authenticated user's client_id.
Scopes:
var scopes = 'https://www.googleapis.com/auth/plus.me https://maps.google.com/maps/feeds/ https://www.googleapis.com/auth/places';
Google+ API Load
Although I can successfully retrieve plus data, the places api does not seem to expose any data. Here is what I have tried:
function makeApiCall() {
/* the plus api does retrieve data, but a similar call to places does not
gapi.client.load('plus', 'v1', function () {
var request = gapi.client.plus.people.get({
'userId': 'me'
});
request.execute(function (resp) {
$(".google-signin").find("img").attr('src', resp.image.url).css('height', '32').css('width', '32');
$("#login-msg").text('Welcome: ' + resp.displayName);
$("img.vote").css('visibility', 'visible');
});
});
*/
gapi.client.load('places', 'v1', function () {
debugger
// the gapi.client does not contain a "places" object
var request = gapi.client.places.get({
'userId': 'me'
});
request.execute(function (resp) {
debugger
});
});
}
Any clarity on this issue is appreciated.
CLARIFICATION EDIT
Perhaps I did not make myself clear. The Google Places API encourages the creation of Events, which are associated with specific Places (of business). We are generating lists based on Google Places API search and details responses (prototype at top-60.bunkerhill.com follow one or more links) We would like businesses to be able to add Events to their associated listing, but cannot allow this without first somehow associating the Places Detail response data with a Google Sign-On; or am I missing something important here?
So the question is "Can a user sign-in to any available Google OAuth API that provides some data which can be used to associate the user with a Places Details entry?
The Google Places API is not the same as the G+ API.
Check out https://developers.google.com/places/documentation/ for instructions on accessing Places data (note that you do not use OAuth for this API - you just include the key from developers.google.com/console in your http request).
Regarding the clarified question: No, the Places API authentication and authorization for creating Events is only via the developer (and your API key), and never the end user who may interact with your application.
For this specific example, you (the developer) can create Events that are associated with a Place, but it would be incumbent on you to make a further association of which end user you wanted to associate with the creation of that Event, and store that metadata within your application if you cared to do so.
Is there a reason having the Places API itself understand this relationship that would be a benefit to your application?

Categories

Resources