Not getting private calendar events from Google - ios

I want to import all events from Google calendar. In my code I will authenticate user first. Once user is sign in successfully then I will call below API using GET request.
https://www.googleapis.com/calendar/v3/calendars/my Email/events?key=my App Key&fields=items(id,start,summary,status,end)
I am getting response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
Once I change my calendar as a public it will give all events details, but if calendar is mark as a private then it’s giving above response.
Any one having idea how to get events details from private calendar?

I think you may need add your access token to access your calendar information, if you use JavaScript library, you can take a look at these sample:
https://developers.google.com/api-client-library/javascript/features/authentication
I have implemented getCalendar using Angular JS + Ionic (using REST API)
https://developers.google.com/google-apps/calendar/v3/reference/
, but I am at work now, will send you later if you need it.
take a look at this example, you may understand how to attached yr request token to your request:
ionicExample.controller("DigitalOceanExample", function($scope, $http, $cordovaOauth) {
$scope.digitalOceanLogin = function() {
$cordovaOauth.digitalOcean("CLIENT_ID_HERE", "CLIENT_SECRET_HERE").then(function(result) {
window.localStorage.setItem("access_token", result.access_token);
}, function(error) {
console.log(error);
});
}
$scope.getDroplets = function() {
$http.defaults.headers.common.Authorization = "Bearer " + window.localStorage.getItem("access_token");
$http.get("https://api.digitalocean.com/v2/droplets")
.success(function(data) {
console.log(JSON.stringify(data.droplets));
})
.error(function(error) {
console.log(error);
});
}
});

I got the solution from this Google Developer console
LINK

Related

Can't Delete Youtube Subscription With API

I have the code setup for the Youtube API with oauth login. Login appears to work properly. I can even see the requests hitting my analytics. However, when I run the code to unsubscribe from a channel, it never works on any channel ID I give it. It should be noted that I'm using the exact example from googles dev docs(see "full sample" option for javascript)... I'm guessing the code is correct and this is some other auth/lookup problem.
API code:
alert("deleting steven!!!!!!");
buildApiRequest('DELETE',
'/youtube/v3/subscriptions',
{'id': 'UCMtFAi84ehTSYSE9XoHefig'});
Stock Youtube API Code:
function executeRequest(request) {
request.execute(function(response) {
console.log(response);
});
}
function buildApiRequest(requestMethod, path, params, properties) {
params = removeEmptyParams(params);
var request;
if (properties) {
var resource = createResource(properties);
request = gapi.client.request({
'body': resource,
'method': requestMethod,
'path': path,
'params': params
});
} else {
request = gapi.client.request({
'method': requestMethod,
'path': path,
'params': params
});
}
executeRequest(request);
}
Here is the error:
{
"error": {
"errors": [
{
"domain": "youtube.subscription",
"reason": "subscriptionNotFound",
"message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
}
],
"code": 404,
"message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
}
}
Remember that the ID you have to send is not the channel ID. It's the ID of the subscriptions.
You can get it by sending request to check your subscriptions with the channel. For example
Request:
buildApiRequest('GET',
'/youtube/v3/subscriptions',
{'forChannelId': 'UCEhZglE9MQ4zTL5ErNXt5mg',
'mine': 'true',
'part': 'snippet,contentDetails'});
Response:
{
"kind": "youtube#subscription",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/KrR9MNb4Xs1eNjWMxAH-f5ccsos\"",
"id": "Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M",
"snippet": {
"publishedAt": "2018-09-30T16:51:47.000Z",
"title": "Rebeca Willett",
"description": "",
"resourceId": {
"kind": "youtube#channel",
"channelId": "UCEhZglE9MQ4zTL5ErNXt5mg"
},
"channelId": "UCWfZYaoFrUOSoHNhCOOqKCQ",
"thumbnails": {
...
}
Using ID in the response to send request for unsubscribing:
buildApiRequest('DELETE',
'/youtube/v3/subscriptions',
{'id': 'Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M'});
Here is the google docs for getting subscriptions ID

The requested user 'chrisb#domainname.com' is invalid

Microsoft Graph sometimes returns a strange result
Client Error:
GET https://graph.microsoft.com/v1.0/me/calendars resulted in a 404 Not Found
{
"error": {
"code": "ErrorInvalidUser",
"message": "The requested user 'chrisb#domain_name.com' is invalid.",
"innerError": {
"request-id": "c229f76d-a9d0-4441-b663-b34f4996cddb",
"date": "2017-11-21T01:23:18"
}
}
}
That issue seems to be strange for me, since I know the user exists since I can login under it.
What I do:
I use stored refresh token to get access token.
Using that access token I try to get list of all user calendars.
At that point it return me fail message.
Question:
What does that error mean - since user is 100% present at Microsoft (I able to get auth token from refresh token and able to login under that user)
I had faced same issue for some MS users only whom specially has very old account, I was passing email of microsoft user like : following
let userInfo = {email: user.email}
let apiParams = {token: access_token, event: newEvent,calendarId: msUserInfo.calendarId, user:userInfo}
Solution:
After I had issue, I have remove 'user' parameter from api and it works for me.
I have set now as following.
I have used Node, node-outlook
const outlook = require('node-outlook');
let newEvent = {
"Subject": objUpdate.title,
"Body": {
"ContentType": "HTML",
"Content": objUpdate.description
},
"Start": {
"DateTime": moment('startDate').toISOString(),
"TimeZone": objUpdate.timeZone
},
"End": {
"DateTime": moment('endDate').toISOString(),
"TimeZone": objUpdate.timeZone
}
};
outlook.calendar.createEvent({token: access_token, event: newEvent ,calendarId: msUserInfo.calendarId
},async function(error, result){
if (error) {
console.log("error: -",error)
throw "Microsoft Calendar Api Err."
}else if (result) {
console.log("Result -")
}
});

Error: "message": "Login Required" when use Youtube Analytics API

I am working with youtube api. when I hit this url "https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=2015-01-01&end-date=2016-01-31&metrics=likes%2Cdislikes&key={API Key}"
it gives 401
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
but I hited in the explorer "https://developers.google.com/apis-explorer/?"
it working fine.
How do I make the first request work?
In your request you are sending key={your key} for an access token you should be sending access_token={your oauth2 access token}
Note: Key is used for public requests. access token is for authenticated requests.
If someone else using JWT authentication on a Google API stumbles upon this question (eg. when using Service Accounts) then make sure to include auth: <your jwtClient> in your API call, like:
First, get the token:
// Configure JWT auth client
var privatekey = require("./<secret>.json")
var jwtClient = new google.auth.JWT(
privatekey.client_email,
null,
privatekey.private_key,
['https://www.googleapis.com/auth/drive']
);
// Authenticate request
jwtClient.authorize(function (err, tokens) {
if (err) {
return;
} else {
console.log("Google autorization complete");
}
});
Then, call the API (but don't forget the auth:jwtClient part)
drive.files.create({
auth: jwtClient,
resource: {<fileMetadata>},
fields: 'id'
}, function (err, file) {
if (err) {
// Handle error
} else {
// Success is much harder to handle
}
});

FBSDKGraphRequest in React Native returning incomplete object

So I have implemented the react native FBSDKGraphRequest and login button. Login is working correctly, but when i attempt a graph request of the user, instead of the complete object i expect the /me endpoint to return
{
"id": "162036280799349",
"birthday": "08/08/1980",
"email": "test_ppjeffg_eight\u0040tfbnw.net",
"first_name": "Test",
"gender": "male",
"last_name": "Eight",
"link": "https://www.facebook.com/app_scoped_user_id/162036280799349/",
"locale": "en_US",
"name": "Test Eight",
"timezone": -8,
"updated_time": "2015-07-28T18:22:16+0000",
"verified": false
}
I just get
Object {name: "Test Eight", id: "162036280799349"}
I very well may be doing the request incorrectly, though I've done everything according to documentation. Here is the relevant source code:
class LoadingOverlay extends BaseComponent{
constructor(props){
super(props);
this._bind(/*'_fetchFriendsRequestFunction'*/);
this.state = {isVisible: true,
token: null,
profileInfo: null}
}
_fetchGraphRequestFunction(){
console.log("start");
var fetchProfileRequest = new FBSDKGraphRequest((error, result) => {
if (error) {
alert('Error making request.');
} else {
// Data from request is in result
console.log(result);
}
}, '/me');
// Start the graph request.
fetchProfileRequest.start();
}
render(){
return(
<Overlay isVisible={this.state.isVisible}>
<BlurView style={styles.background} blurType="dark">
<FBSDKLoginButton
onLoginFinished={(error,result)=>{
if (error){
alert('Error Logging In.');
} else {
if (result.isCanceled){
alert('Login Cancelled.');
} else {
FBSDKAccessToken.getCurrentAccessToken((token)=>{
console.log(token.tokenString);
this._fetchGraphRequestFunction();
})
}
}
}}
onLogoutFinished={()=>console.log('Logged Out.')}
readPermissions={['public_profile', 'email', 'user_birthday', 'user_friends']}
publishPermissions={['publish_actions']}/>
</BlurView>
</Overlay>
);
}
}`
You can request additional parameters from Facebook by either appending them to the uri like this:
/me?fields=id,name,email
or by calling the addStringParameter function on the FBSDKGraphRequest object like this:
fetchProfileRequest.addStringParameter('picture,email,gender','fields');
However, what fields you get in return depends on the permission of your app and the settings of the user.
Also, note this little trick from the ios FB sdk documentation: https://developers.facebook.com/docs/reference/ios/current/class/FBSDKLoginButton/
Note, that if read permissions are specified, then publish permissions should not be specified.
So try sending an empty publishPermissions parameter and see if that fixed it.
More information here:
Publish or manage permissions are not permited to to be requested with read permissions FACEBOOK SDK
https://coderwall.com/p/gkeqcq/request-read-and-publish-permissions-simultaneously-using-ios-facebook-support
I'd love to see an example of the flow to make this work in react native if anyone has it.

Querying Tumblr Tags through OAuth.io Unauthorized

I'm getting a 401 unauthorized error
{ "meta": { "status": 401, "msg": "Not Authorized" }, "response": [] }
when trying to load Tumblr tags through OAuth.io as follows:
OAuth.popup('tumblr', {cache:true}).done(function(api) {
console.log("Successfully OAuthed")
api.get("http://api.tumblr.com/v2/tagged?tag=lol").done(function(results) {
console.log(results);
})
});
All other queries work fine. If I query for /user/dashboard, for example, the logged in user's dashboard is successfully returned.
Did you try adding your api_key to the api.get
api.get("http://api.tumblr.com/v2/tagged?tag=lol&api_key={consumer_key}").done(function(results) {
console.log(results);
})

Resources