Copyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md for license terms and full copyright notice.
The @itwin/node-cli-authorization package contains a Node.js command-line based client for authorization with the iTwin Platform by default and is configurable to work with any OAuth2.0 based provider.
The OAuth2.0 workflow used in this package is Authorization Code + PKCE, for more information about the flow please visit the Authorization Overview Page.
Choose "Desktop/Mobile" as your application type when registering for use with this client.
Note that your registered application's redirectUri must start with http://localhost:${redirectPort}
.
See the AccessToken article in the iTwin.js documentation for background on authorization in iTwin.js.
const authClient = new NodeCliAuthorizationClient(yourConfig);
await authClient.signIn();
IModelHost.authorizationClient = authClient;