URL : https://graph.microsoft.com
Client ID : <Application client ID of Azure App>
Client Secret : <Clients Secrets Value of Azure App>
Token Service URL : https://login.microsoftonline.com/<Directory Tenant ID of Azure App>/oauth2/v2.0/token
or <Token Service URL : <Application OAuth 2.0 token Endpoint(v2) of Azure App>
Scope : https://graph.microsoft.com/.default
mkdir <cds-azure-example-folder>
cd <cds-azure-example-folder>
cds init
"dependencies": {
...
"@sapmentors/cds-scp-api": "latest"
},
npm install
@impl:'msgraph-user-service.js'
@cds.query.limit: 100
service MSGraphService @(requires:'any'){
@cds.persistence.skip
entity User {
key aad_id : String;
username : String;
displayName : String;
givenName : String;
surname : String;
isAzureActiveDirectory : Boolean;
}
}
const cdsapi = require("@sapmentors/cds-scp-api");
const readFunction = async (req) => {
let destination = 'MSGraph'
const url = `/v1.0/users/`
const service = await cdsapi.connect.to(destination);
const graphUser = await service.run({
url: url
})
let users = graphUser.value.map(graph_user => {
var user = {}
user.aad_id = graph_user.id
user.username = graph_user.userPrincipalName
user.displayName = graph_user.displayName
user.givenName = graph_user.givenName
user.surname = graph_user.surname
user.isAzureActiveDirectory = true
return user
})
return users
}
module.exports = (srv) => {
srv.on('READ', 'User', readFunction)
}
cds watch
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
8 | |
7 | |
7 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 |