I want to get the User's profile that shared a Calendar with me but this call needs the id or userPrincipalName:
GET /users/{id | userPrincipalName}
The shared calendar only returns:
{
"id": "**********************************************=",
"name": "Lala Lalala",
"color": "auto",
"changeKey": "Epg+nQ9k3kuTN16cfoLtwAAAsZgDvA==",
"canShare": false,
"canViewPrivateItems": false,
"canEdit": true,
"owner": {
"name": "Lala Lalala",
"address": "Lalala#outlook.com"
}
}
So how can I get the id or userPrincipalName of the shared calendar's owner?
For Work/School Accounts (Azure AD tenants), the userPrincipalName is the owner's address (i.e. alias#aad.domain.com):
"owner": {
"name": "Lala Lalala",
"address": "Lalala#outlook.com"
}
Assuming they're in the same tenant as your, you can retrieve their profile using GET https://graph.microsoft.com/v1.0/users/{owner.address}.
Important: This does not, however, apply to Personal Accounts (MSA/Outlook.com). I only mention this because your example used Lalala#outlook.com as the address.
Since Outlook.com is effectively a "single user" tenant, the only user you can retrieve is yourself (/me). Just as you cannot access a user's data from another company's AAD, you cannot retrieve another Outlook.com user's profile. If you consider the pricacey implications of my access your personal contact information, it makes sense why this rule is in place.
No directly way to implement what you want. But you can get the id or userPrincipalName by two steps:
Get calendars whose owner is not you, the response like you have posted(official docs):
https://graph.microsoft.com/v1.0/me/calendars
Use the address in the owner to call the following API:
https://graph.microsoft.com/v1.0/users/{address}
The response with id and userPrincipalName:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"id": "5eec0ff7-b007-48c4-87ae-7cddb085f234",
"businessPhones": [],
"displayName": "...",
"givenName": "...",
"jobTitle": null,
"mail": "test#test.com",
"mobilePhone": "8612345678",
"officeLocation": "No WorkSpace",
"preferredLanguage": null,
"surname": "s",
"userPrincipalName": "test#test.com"
}
Related
I'm looking for advice on the best way to organize the way I manage data in an angular 14 application. Basically, this web application consist in groups of forms through several pages that are nested in three levels of information as follows :
Parent form : Intervention x (Application can have several interventions as this one)
Child form : Enterprise y (One intervention can have several enterprises)
Child form : Employee z (several individuals associated to an enterprise)
Each form information is collected using reactive forms through different pages that are shown in the screen thanks to router-navigation module of Angular.
What have I tried so far:
I started developing the application from the individual level, and then, I share the information between the pages using a service called on the component of each page. Later, I created the enterprise forms and another service specifically called to store their information.
In order to make the data persistent, I am currently using json-server to store the data in a .json file and simulate an API behavior. This allows me to do Http calls from the services in order to get, put and post the Data in the .json.
Is there a better way?
Right now I'm developing the intervention form, it is becoming very hard to maintain the child forms and I guess there is a better way to manage data for this kind of applications.
Here an example of the .json server structure :
{"interventions":
[{
"id": 1,
"user": "",
"email": "",
"enterprises":
[{
"id": 1,
"name": "",
"address": "",
"employees":
[{
"id": 1,
"name": "",
"email": ""
},
{
"id": 2,
"user": "",
"email": ""
}]
},
{
"id": 2,
"user": "",
"email": "",
"address": "yyy",
}]
},
{
"id": 2,
"user": "",
"email": "",
"address": "yyy",
}]
}
Hope this question is clear, I can provide more details if needed.
Thank you in advance.
Making a script to create uniform gmail signatures and I noticed only a few users, out of the hundreds, have both user.organizations[0] and user.organizations[1]. This of course is bothering me terribly. I see on these users that the 1 is the primary and visible in GAC while the rest of the users that is the 0 that is visible. Is there a way to delete the extra organizations inside a user?
Yes, this is possible and it is very simple.
We will need to use 2 methods:
Users.get (https://developers.google.com/admin-sdk/directory/reference/rest/v1/users/get) to check every user to confirm they have the correct value in the organizations property.
Users.update (https://developers.google.com/admin-sdk/directory/reference/rest/v1/users/update) to replace the existing value on that property.
Steps:
Feel free to use the API Explorer available in the documentation above to test these API calls.
Use the Users.get method to obtain the data of the user you are interested in updating. You can make the result shorter by specifying a value in the fields parameter like so:
"fields": "primaryEmail,organizations"
This will return the data of the user including their primary email and a list of the organization(s) the user has.
{
"primaryEmail": "user#domain.com",
"organizations": [
{
"title": "Accountant",
"primary": true,
"customType": "",
"department": "Accounting",
"description": "Full Time accountant",
"costCenter": "CompanyTotalPro"
},
{
"title": "Accountant",
"primary": false,
"customType": "",
"department": "Accounting",
"description": "Part Time accountant",
"costCenter": "SecondaryCompany"
}
]
}
This response will contain the data of one or more organizations, you will only need to copy the value you want to maintain and make an API call using the Users.update method. Like so:
Don't worry about the code. What you need to see is that we are essentially obtaining the list of organizations and removing the one we don't want, and using the new set of information to overwrite the old one. Use this for reference.
gapi.client.directory.users.update({
"userKey": "user#domain.com",
"resource": {
"organizations": [
{
"title": "Accountant",
"primary": true,
"customType": "",
"department": "Accounting",
"description": "Full Time accountant",
"costCenter": "CompanyTotalPro"
}
]
}
})
Use null to clear the value.
"organizations": null
I am building a tool automatically scan a local folder and upload files to BIM360 Docs, with 2 legged authentification, so far files can already uploaded to BIM360 Docs using Forge Data Management API however the "updated by" field is empty. what i want to accomplish is load the current login user and set the current user's name as updated by.
I cannot find anywhere i can use from Forge API to set the "updated by", can anyone suggest?
Thanks a lot.
When you post/patch an item/version there are two fields you can specify that suit your needs - lastModifiedUserId and lastModifiedUserName:
"attributes": {
"mimeType": "appplication/pdf",
"displayName": "version-test.pdf",
"name": "version-test.pdf",
"extension": {
"data": {
"tempUrn": null,
"storageType": "OSS",
"properties": {},
"storageUrn": "urn:adsk.objects:os.object:wip.dm.prod/3c8f6bbc-fe5c-4815-a92e-8b8635e7b1cb.pdf"
},
"version": "1.0",
"type": "versions:autodesk.bim360:FileVersions",
"schema": {
"href": "/schema/v1/versions/versions%3Aautodesk.bim360%3AFileVersions-1.0"
}
},
"createUserName": "John Doe",
"createTime": "2016-04-01T11:09:03.000Z",
"createUserId": "BW9RM76WZBGL",
"lastModifiedUserName": "John Doe",
"lastModifiedUserId": "BW9RM76WZBGL",
"versionNumber": 2,
"lastModifiedTime": "2016-04-01T11:11:18.000Z"
},
"type": "versions",
"id": "urn:adsk.wipprod:fs.file:vf.d34fdsg3g?version=2",
"links": {
"self": {
"href": "/data/v1/projects/b.6f8813fe-31a7-4440-bc63-d8ca97c856b4/versions/urn%3Aadsk.wipprod%3Afs.file%3Avf.b909RzMKR4mhc3O7UBY_8g%3Fversion%3D1"
}
}
Normally, we would suggest you to use 3 legged token to modify a file in BIM360 Docs, because that will keep track the users who made the modification to that file(updated by). Yes you can also use 2 legged token for file management in BIM360 for now, but this behaviour may change in the future, and we will clearly mention in our blog if it happens.
There is no user information for any changes to the BIM360 files with 2 legged token, but there is one way, follow the Upload Files to BIM 360 Document Managemen Tutorial, in Step 7 & 8, add the x-user-id parameter in the header as the following picture, you will see the last modified user is filled.
Check this https://forge.autodesk.com/en/docs/bim360/v1/reference/http/users-GET/ if you want to know how to get the x-user-id information, should be uid(Autodesk ID).
I created some permissions(permission_fiware table) in Horizon regarding urls that can or cant be seen.I created permission(name:Upload images, with resource: "/image_upload") and role(role_fiware) admin that has this permission.
Now i want to check whether some user that is logged in to my application can view that page on url "/image_upload" that i defined in horizons permission.So my guess is i should first check what roles user has, and after that whether those roles that user is assigned have required permission.
So, my question is next:
How can i list what permission one specific user has.
In Keyrocks API:
http://docs.keyrock.apiary.io/#reference/keystone-extensions/role-user-relationships/list-users-role-assignments
i found how i can list all permissions for a specific role
http://keyrock/OS-ROLES/roles/role_id/permissions
but how can i get information about what roles(role_fiware) are assigned to a user?
As stands in the FIWARE-IDM documentation doing a request against the resource user of your IDM host using the access_token, will return the user information, and within that information you will find the roles that user have assigned:
GET
/user?access_token=XXXXXXXXXXXXXXXXXXXX
Response:
{
"organizations": [{
"website": "",
"city": "",
"name": "Franchise1",
"img": "/static/dashboard/img/logos/small/group.png",
"domain_id": "default",
"enabled": true,
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"roles": [{
"name": "Franchise manager",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}],
"email": "",
"description": "Test Organization"
}],
"displayName": "user1",
"roles": [{
"name": "End user",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}],
"app_id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"email": "user1#test.com",
"id": "user1"
}
I'm trying to query Box API to identify if a user has a free or a paid account. So far I was able to query:
https://api.box.com/2.0/users/me?fields=enterprise
and I checked that if a user have a free account the attribute "enterprise" is null. But the problem is I can't distinguish between a paid account and a developer account because the have the same info on enterprise object:
{
"type": "user",
"id": "123",
"enterprise": {
"type": "enterprise",
"id": "456",
"name": "..."
}
}
Is there a way to identify theses 3 types of account (free, paid and developer)?
Currently you can only check whether or not the user has an enterprise by calling the GET /users/me endpoint.
{
"type": "user",
"id": "123",
"enterprise": {
"type": "enterprise",
"id": "456",
"name": "..."
}
}
and checking to see if the enterprise attribute is null to distinguish between a personal and enterprise user.