Google Calendar Unable to Update Events - google-api

I had my Google calendar application almost working, I am still able to list all the events on the Primary Calendar and I can edit on Google and see the updated results on my calendar.
The problem is that my:
var eventToUpdate = gapi.client.calendar.events.get({
is getting an error 404.
From what I've been reading people who have had this issue previously were sending the wrong Key or wrong Event ID. But I've tested the values using
https://developers.google.com/calendar/v3/reference/events/update
& I get a success 200 back from Google.
Here is my event drop:
eventDrop: function( eventDropInfo ) {
gapi.auth.setToken('<?php echo $google_auth['access_token']; ?>');
handleAuthClick;
gapi.client.init({
apiKey: API_KEY,
clientId: CLIENT_ID,
discoveryDocs: DISCOVERY_DOCS,
scope: SCOPES
}).then(function () {
}, function(error) {
appendPre(JSON.stringify(error, null, 2));
});
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
var eventToUpdate = gapi.client.calendar.events.get({
"calendarId": 'primary',
"eventId": eventDropInfo.id
});
There's more but that's the main Google APIs part.
I thought it could be the Key, however the Key works to grab the calendar information and is able to be used for my other Google stuff. (Drive, Login etc.)
I thought maybee it was the wrong calendar ID but using the Google "Try This API" It seems the Calendar ID + Event ID is perfect as Google gives me success.
Below you can see the console error, apologies if I've missed off anything important.
Thank You!
Error 404 From Console
--- Updated with more info
This shows Google References accepting the event ID and updating the event
This is the data I've entered to get the 200 success above
This is the URL showing the JSON google print out
Just to note, I've checked the scopes and the 2 I am using are:
var SCOPES = "https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/calendar.events";
The only others I can find are Read Only so I doubt it's the scopes.
Also the code seems to work as the only error I see is Google giving a 404, the loading of the events and calendar work it's just update that gives the 404.
As you can see through the screenshots I've updated the event ID i'm using to test is the same in my code as in the References test.

This is now working.
The problem was with my script not setting the OAuth Token correctly. It was saving the full JSON string instead of just the token.
After amending the login and getting the correct OAuth it works as it should :)
Thanks for the help!

Related

Classroom API Invitations.list does not return userId field

A short description of the issue: userId field is not present in the invitations.list and invitations.get response.
What steps will reproduce the problem?
Create a course in google classroom
Authenticate in google OAuth2.0 playground
Send a request to list all sent invitations.
What is the expected output? What do you see instead? If you see error messages, please provide them. I expected to get the userId as a part of the response. After authentication and sending the request to the "https://classroom.googleapis.com/v1/invitations?courseId=*my course id*" I get the following response:
{
"nextPageToken": "*next page token*",
"invitations": [
{
"courseId": "*course id*",
"role": "STUDENT",
"id": "*invitation id*"
}
]
}
However, the documentation states that there should also be a "userId" field, which I am not seeing here.
The same thing happens when I use the "Try this API" section in the documentation. The response code is 200 but there is no userId.
Answer:
It appears that the only the users that have not accepted an invitation have their user IDs appear.
This could be a bug...
The documentation for the invitations resource doesn't make it clear as to whether this is intended behaviour or not. I used the Try this API feature of the invitations.list method and I was able to retrieve the userId for some users, not not others. I followed up my search and it appears you have already filed this issue with Google on Issue Tracker:
Invitations.list does not return userId field
Things to do:
To make sure that you're always receiving the userId when it is available, you can specify in the request to retrieve all response fields with a wildcard (*). You can test this on the Try this API feature by entering the courseId, expanding Show standard parameters and entering a * in the fields box.
Note: As this appears to be a bug, using the wildcard is not a solution; but something that may be helpful for users if attempting to retrieve a response key that isn't default.
REST Resource: invitations | Google Classroom API
Method invitations.list | Google Classroom API
Invitations.list does not return userId field | Google Issue Tracker

Not getting response from upwork API

I am trying to get all companies using below api
var companies = new Companies(api);
companies.getList(function (error, data) {
console.log(data);
console.log(error);
});
My app have all the permission still I am getting below error,
{"server_time":1586893220,"error":{"status":403,"code":403,"message":"This APP has no access to requested resource"}}
Please let me know what I am missing.
According to the documentation for List companies API, the API key must have the following permissions: "View the structure of your companies/teams", see section "Required key permissions".
Please, revisit your key and adjust the permissions accordingly.

Google People API gapi.client.people is undefined

After I init the google people api gapi.client like so:
gapi.client.init with object containing the scope, api key, and client id:
init_people_api = async () => {
await gapi.client.init({
apiKey: API_KEY,
clientId: CLIENT_ID,
scope: "https://www.googleapis.com/auth/contacts",
})
await gapi.client.people.people.connections.list({
'resourceName': 'people/me',
'pageSize': 10,
'personFields': 'names,emailAddresses',
}).then(function(response) {
console.log(response)
})
}
When I call gapi.client.people, it is undefined.
gapi.client gives me this object:
Can anyone help me figure out how to debug this? Im doing what the tutorial indicates to do. My user is authenticated, I have waited for the api library to load, waited for gapi.client to initialize, but now when I ask for the gapi.client.people, nothing is there. How can I load this function?
You need to set the discoveryDocs parameter to People API discovery doc ["https://www.googleapis.com/discovery/v1/apis/people/v1/rest"] in order to get the People API loaded in GAPI. Please look at the documentation sample for an example of how to do this.
I seem to get the same problem when my API key is invalid. Make sure that you're creating and using a separate API key and not accidentally using the client secret instead. Also, double check that your API key isn't restricted in any way in the its settings.
If you don't find any problems there, try regenerating your API key or making a new one. Let me know if you're still running into this problem! :)

The requested application with ID xxxxxx was not found

I 'm trying to post/get score from google play leaderboards
I met all the meta-tag from the documentation including my client id
<meta name="google-signin-client_id" content="XXXXXX-YYYYYYYYYYY.apps.googleusercontent.com" />
I also have setup the google sign-in system and all is fine, however when I try to call the leaderboards API I get the message error: The requested application with ID xxxxxx was not found
I am calling the API like the mentioned in the doc
gapi.client.request({
path: '/games/v1/leaderboards/LEADERBOARD-ID',
params: { maxResults: 3 },
callback: function(response) {
console.log(response);
}
});
I am not sure if the problem is the missing argument to execute a request.
Try to use this API requests method.
gapi.client.Request
An object encapsulating an HTTP request. This object is not
instantiated directly, rather it is returned by gapi.client.request.
There are two ways to execute a request. We recommend that you treat
the object as a promise and use the then method, but you can also use
the execute method and pass in a callback.
You can refer to this Github post for additional reference.
This message: W/AchievementAgent( 3558):
{"code":404,"errors":[{"message":"The requested application with ID
571707973781 was not found.","domain":"global","reason":"notFound "}]}
is a little cryptic but points to a mismatch with the auth
configuration on the console and the application.
You'll want to double check the keystore SHA1 fingerprint of the
keystore you signed the app with and the one configured in the dev
console.
It could also be the bundle ID, but that is hard to mess up since it
is part of the resource data used when running Setup for the plugin.
Also, it could be that the player is not a tester for this game.
For anyone having the same issue, you need to publish the beta version of the game to be able to interact with the game scoreboard.
Note: In the beta version, only tester accounts added to the game can access the scoreboard.

Getting logged in identities with an id token via Xamarin's Auth0.SDK

The Auth0User object returned from LoginAsync() contains a list of the logged in identities.
But how do I get this upon without seeing the login dialog LoginAsync presents - I'd just like to use the id token saved from the previous login?
There seems to be a tokeninfo endpoint for this, but Xamarin's Auth0.SDK seems to eliminate dealing with REST - so feel like I'm missing something.
If the user has already logged in, you can do a refresh:
var client = new Auth0.SDK.Auth0Client ("XXXXXXX.auth0.com", "XXXXXXXXXXXXXXXXX");
await client.RefreshToken();
Console.Writeline(client.CurrentUser);

Resources