@azure/identity-broker 1.0.1-alpha.20240223.1 → 1.0.1-alpha.20240320.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -65,8 +65,8 @@ useIdentityPlugin(nativeBrokerPlugin);
|
|
|
65
65
|
const credential = new InteractiveBrowserCredential({
|
|
66
66
|
brokerOptions: {
|
|
67
67
|
enabled: true,
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
After calling `useIdentityPlugin`, the native broker plugin is registered to the `@azure/identity` package and will be available on the `InteractiveBrowserCredential` that supports WAM broker authentication. This credential has `brokerOptions` in the constructor options.
|
|
@@ -101,7 +101,40 @@ main().catch((error) => {
|
|
|
101
101
|
process.exit(1);
|
|
102
102
|
});
|
|
103
103
|
```
|
|
104
|
-
|
|
104
|
+
|
|
105
|
+
For a complete example of using an Electron app for retrieving a window handle, see [this sample](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity-broker/samples/v1/typescript/src/index.ts).
|
|
106
|
+
|
|
107
|
+
### Use the default account for sign-in
|
|
108
|
+
|
|
109
|
+
When the `useDefaultBrokerAccount` option is set to `true`, the credential will attempt to silently use the default broker account. If using the default account fails, the credential will fall back to interactive authentication.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { nativeBrokerPlugin } from "@azure/identity-broker";
|
|
113
|
+
import { useIdentityPlugin, InteractiveBrowserCredential } from "@azure/identity";
|
|
114
|
+
|
|
115
|
+
useIdentityPlugin(nativeBrokerPlugin);
|
|
116
|
+
|
|
117
|
+
async function main() {
|
|
118
|
+
const credential = new InteractiveBrowserCredential({
|
|
119
|
+
brokerOptions: {
|
|
120
|
+
enabled: true,
|
|
121
|
+
useDefaultBrokerAccount: true,
|
|
122
|
+
parentWindowHandle: <insert_current_window_handle>
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// We'll use the Microsoft Graph scope as an example
|
|
127
|
+
const scope = "https://graph.microsoft.com/.default";
|
|
128
|
+
|
|
129
|
+
// Print out part of the access token
|
|
130
|
+
console.log((await credential.getToken(scope)).token.substr(0, 10), "...");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
main().catch((error) => {
|
|
134
|
+
console.error("An error occurred:", error);
|
|
135
|
+
process.exit(1);
|
|
136
|
+
});
|
|
137
|
+
```
|
|
105
138
|
|
|
106
139
|
## Troubleshooting
|
|
107
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/identity-broker",
|
|
3
|
-
"version": "1.0.1-alpha.
|
|
3
|
+
"version": "1.0.1-alpha.20240320.2",
|
|
4
4
|
"sdk-type": "client",
|
|
5
5
|
"description": "A native plugin for Azure Identity credentials to enable broker authentication such as WAM",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"build:test": "tsc -p . && dev-tool run bundle",
|
|
13
13
|
"build": "npm run extract-api && tsc -p . && dev-tool run bundle",
|
|
14
14
|
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
15
|
-
"clean": "rimraf dist dist-esm types \"*.tgz\" \"*.log\"",
|
|
15
|
+
"clean": "rimraf --glob dist dist-esm types \"*.tgz\" \"*.log\"",
|
|
16
16
|
"execute:samples": "echo skipped",
|
|
17
17
|
"extract-api": "tsc -p . && api-extractor run --local",
|
|
18
18
|
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|