Update user's properties (aboutMe, skills) with app permission - json

When I am trying to update the user's aboutMe property via /v1.0/users/[user-principal-name] I get following error message:
{
"error":
{
"code": "-1, Microsoft.Office.Server.Directory.DirectoryObjectUnauthorizedAccessException",
"message": "Attempted to perform an unauthorized operation.",
"innerError":
{
"request-id": "a0112fff-de9a-4917-b627-c4103a04a105",
"date": "2018-03-22T11:02:46"
}
}
}
What I have done far:
Added application permissions User.ReadWrite.All and Directory.ReadWrite.All to registered app under apps.dev.microsoft.com
Concent for app was granted by admin via https://login.microsoftonline.com/[tenant]/adminconsent?client_id=[client-id]&state=12345&redirect_uri=[redirect-uri]
I am able to update the user's profile image or a property like mobilePhone.
What am I doing wrong/is it not possible to update those attributes?

Related

Creating a Plan in Planner

I want to create a plan in Planner. The endpoint I call is:
https://graph.microsoft.com/beta/planner/plans
In return I get:
{
"error": {
"code": "",
"message": "You do not have the required permissions to access this item, or the item may not exist.",
"innerError": {
"request-id": "2654b7da-4ee4-47b8-83f8-e9514088c095",
"date": "2018-10-01T10:57:34"
}
}
}
My permissions and scopes are:
SCOPES = ['User.Read', 'Group.ReadWrite.All']
I gave Admin Consent for these permissions.
As a payload I send:
{
"title": "test",
"owner": "<myID>"
}
Where <myID> is the ID of the account requested per /me
Still it does not work - what did I miss?
The owner property should be a Group's id, not the User's id. Users can only have one individual "plan". Since this already exists, you cannot create a new one.
From the documentation:
In the request body, supply a JSON representation of plannerPlan object. The owner property must be set to an id of a group object.

Google Classroom, delete teacher from course backend Error 500

I'm able to delete a teacher from a course but in this particular case I get this error (In Classroom API Reference ):
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"status": "INTERNAL"
}
}
From my NodeJS app:
{ code: 500,
message: 'Internal error encountered.',
errors:
[ { message: 'Internal error encountered.',
domain: 'global',
reason: 'backendError' } ],
status: 'INTERNAL' }
The code (NodeJS app):
let classroom = google.classroom('v1');
let data = {
auth : auth,
courseId : idCurso,
userId : emailDocente
};
classroom.courses.teachers.delete(data, (err, response) => {
//...code
});
I get this error from the UI.
More Info:
There are two teachers in the course: myemail#mydomain.com and
admin#mydomain.com admin#mydomain.com is the owner.
I need to remove myemail#mydomain.com The user is active and exists in GSuite Admin
SDK.
courseState is ACTIVE
The error was caused by: the teacher was the owner of the google drive's folder. I had to delete from drive and the trash too. Developers should validate this and show a more clear message or delete the drive folder before deleting the teacher. Hope you guys update this. Thanks.
Update: I haven't been able to transfer ownership using drive API due to the fact that the user which I'm using to connect to the API doesn't have permission to change ownership I cannot have the real user to log in and change ownership because it's an automated process which runs every x minutes. I have to assign ownership of the drive folder to the user I connect to the API -not the real user- otherwise this will not work. I hope Google devs fix this.

Unable to create webhook for Autodesk BIM 360 docs project

I am trying to create a webhook for Autodesk BIM 360 project and ended with this error - "Access denied for the scope that you are trying to create hook on". I am using Postman to test the webhook creation - Here is the response which I am getting -
{
"hooks": [],
"errors": [
{
"id": "071ec72d-20b5-40c1-9451-ee9cdf573984",
"status": 403,
"code": "FORBIDDEN_ERROR",
"detail": [
"Access denied for the scope <projectId> that you are trying to create hook on"
],
"source": {
"sysType": "adsk.wipprod",
"eventType": "fs.file.added",
"callbackUrl": "http://6bd04cad.ngrok.io/webhooks/bim360",
"scope": {
"folder": "<projectId>"
},
"hookAttribute": null
}
}
]
}
What are the scopes you are passing on, did you follow this tutorial? Has the trial been activated for your keys?
https://developer.autodesk.com/en/docs/webhooks/v1/tutorials/create-a-hook-data-management/
I was facing this issue due to having old forge application which didn't configure the Webhook. Now I have enabled it and it's fixed.
Now I am facing a different issue which is related to access denied. Here is the detail -
creating a Webhook for BIM 360 docs using Autodesk forge custom integration. I am following this Webhook API documentation https://developer.autodesk.com/en/docs/webhooks/v1/reference/http/systems-system-events-event-hooks-POST/ and am constantly getting this response.
{
“id”: “888134c7-fd22-4676-b907-d8441477dde4",
“status”: 403,
“code”: “FORBIDDEN_ERROR”,
“detail”: [
“Access denied for the scope b.2210c698-4e4b-47d0-b579-f92a969ef365 that you are trying to create hook on”
]
}
From your question, it seems that you used the projectId or hubId, make sure to use folderId as the scope, it should be similar to urn:adsk.wipprod:fs.folder:abcd1234

Microsoft Graph API: Subscribing to MailboxSettings

Is it possible to subscribe to changes of MailboxSettings - specifically AutomaticRepliesSetting?
Trying to POST this to /subscriptions on the beta API.
{
"changeType":"updated",
"notificationUrl":"https://example.com/microsoft/notify",
"resource":"users/karel#example.com/mailboxSettings",
"expirationDateTime":"2018-05-11T08:05:26.6920740Z",
"clientState":"QUUvRXJ5beHI9VEvn6hq"
}
Getting back:
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: Forbidden; Reason: Forbidden]"
The application has admin consent for Calendars.ReadWrite, User.Read.All and MailboxSettings.ReadWrite
I can successfully subscribe to calendar changes, so nothing is wrong with the implementation.
Subscribing to the root /users/karel#example.com endpoint gives:
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: InternalServerError; Reason: Internal Server Error]",
"innerError": { "request-id": "3caffc72-9507-4bb7-9eab-56e8ecaaab83", "date": "2018-05-08T09:22:16" }
}
}
This isn't supported. From the documentation:
Using the Microsoft Graph REST API, an app can subscribe to changes on the following resources:
Messages
Events
Contacts
Users
Groups
Group conversations
Content shared on OneDrive including drives associated with SharePoint sites
User's personal OneDrive folders

How can I trigger a Google Apps Script function from the Google API PHP Client with the authentication I have set already?

I'm struggling to trigger a Google Apps Script Function which builds many dropdowns of a Google Spreadsheet.
I need this data to be updated daily on this Google Spreadsheet so I must call the function.
Seems like I'm required to have a client-side authentication which I'm reluctant to force it to happen.
I have set already the Google API PHP Client which does batch updates, get requests and control users and its roles.
Here's how the code looks like:
public function updateTemplate ()
{
$client = $this->getClient();
$service = new Google_Service_Script($client);
$scriptId = $this->gScriptId;
// Create an execution request object.
$request = new Google_Service_Script_ExecutionRequest();
$request->setFunction('SetUpNewSpreadsheet');
try {
// Make the API request.
$response = $service->scripts->run($scriptId, $request);
echo "here<pre>";
print_r($response);
exit;
I'm getting the following response error:
Caught exception: {
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [ {
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"domain": "global",
"reason": "unauthorized"
} ]
, "status": "UNAUTHENTICATED"
}
}
I've checked the message errors and docs already. I'm wondering if maybe I'm missing something or if I can find a way to execute that request without forcing a client-side login?
Has anyone been through it?