Skip to content

Commit 432d8ce

Browse files
musaleMnickii
andauthored
fix: check the options scopes are not empty when getting access token (#3256)
* Check the options scopes are not empty when getting access token * Update the node version to 18+ for devcontainers * Address prettier complaints * Update packages/providers/mgt-msal2-provider/src/Msal2Provider.ts Co-authored-by: Nickii Miaro <[email protected]> --------- Co-authored-by: Nickii Miaro <[email protected]>
1 parent 5551351 commit 432d8ce

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-16",
2+
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-18",
33
"customizations": {
44
"vscode": {
55
"extensions": [
@@ -14,4 +14,4 @@
1414
}
1515
},
1616
"forwardPorts": [3000, 6006]
17-
}
17+
}

packages/providers/mgt-electron-provider/src/Authenticator/ElectronAuthenticator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ export class ElectronAuthenticator {
344344
*/
345345
protected async getAccessToken(options?: AuthenticationProviderOptions): Promise<string | undefined> {
346346
let authResponse: AuthenticationResult | null = null;
347-
const scopes = options?.scopes ? options.scopes : this.authCodeUrlParams.scopes;
347+
const scopes = options?.scopes?.length ? options.scopes : this.authCodeUrlParams.scopes;
348348
const account = this.account || (await this.getAccount());
349349
if (account) {
350350
const request = {

packages/providers/mgt-msal2-provider/src/Msal2Provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,8 @@ export class Msal2Provider extends IProvider {
733733
* @return {*} {Promise<string>}
734734
* @memberof Msal2Provider
735735
*/
736-
public async getAccessToken(options?: AuthenticationProviderOptions): Promise<string> {
737-
const scopes = options ? options.scopes || this.scopes : this.scopes;
736+
public async getAccessToken(opts?: AuthenticationProviderOptions): Promise<string> {
737+
const scopes = opts?.scopes?.length ? opts.scopes : this.scopes;
738738
const accessTokenRequest: SilentRequest = {
739739
scopes,
740740
account: this.getAccount()

0 commit comments

Comments
 (0)