- Daemon/serverless applications Client Credential Flow
- Web Applications OIDCStrategy
- Web APIs BearerStrategy
- Forwarding user identity On Behalf Of Flow
- Key Vault and Managed Identity
- Register a web app, no redirect uri
- Under the Expose an API section, add an appid URI, for example
https://<tenantname>.onmicrosoft.com/server
- Add a scope called
myscope
- Update the following lines in
server.js
:
var tenantID = "<tenantid>" ; // guid;
var clientID = "<clientid>" ; // guid
var audience = "<appiduri>" ; // example "https://tenantname.onmicrosoft.com/server"
- Run
npm start
, your API is now running onhttp://localhost:5000
- To verify, visit
http://localhost:5000/admin
, you should get a 401.
- Register a web app
- Redirect URI of
http://localhost:3000/auth/openid/return
- Enable id_token
- Under API permissions, grant access to
https://<tenantname>.onmicrosoft.com/server/myscope
, ensure you grant consent. - Add a client secret, note down it's value.
- Update values in config.js, specifically the following
var tenantName = '<tenantname>';
var tenantID = '<tenantid>';
var clientID = '<clientid>';
var clientSecret = '<clientsecret>';
....
....
exports.resourceURL = '<appiduri>';
- Run
npm start
, and visithttp://localhost:3000
in your favorite browser. Verify that you can call the serverAPIApp using the "Call API" menu item.