Skip to content

Commit

Permalink
Chore: Update MsGraph JavaScript SDK (#1568)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElinorW authored Apr 7, 2022
1 parent c960dbe commit 9a8652f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
21 changes: 12 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@fluentui/react": "8.43.0",
"@microsoft/applicationinsights-react-js": "2.3.1",
"@microsoft/applicationinsights-web": "2.7.1",
"@microsoft/microsoft-graph-client": "2.1.0",
"@microsoft/microsoft-graph-client": "3.0.2",
"@monaco-editor/react": "4.3.1",
"@ms-ofb/officebrowserfeedbacknpm": "file:packages/officebrowserfeedbacknpm-1.6.6.tgz",
"adaptivecards": "1.2.3",
Expand Down Expand Up @@ -124,4 +124,4 @@
"reportFile": "test-report.xml",
"indent": 4
}
}
}
14 changes: 10 additions & 4 deletions src/app/services/actions/query-action-creator-util.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { InteractionType } from '@azure/msal-browser';
import {
AuthenticationHandlerOptions,
GraphRequest,
ResponseType
} from '@microsoft/microsoft-graph-client';
import {
MSALAuthenticationProviderOptions
} from '@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProviderOptions';
AuthCodeMSALBrowserAuthenticationProviderOptions
} from '@microsoft/microsoft-graph-client/authProviders/authCodeMsalBrowser';

import { authenticationWrapper } from '../../../modules/authentication';
import { IAction } from '../../../types/action';
import { ContentType } from '../../../types/enums';
import { IQuery } from '../../../types/query-runner';
Expand Down Expand Up @@ -95,11 +97,15 @@ function createAuthenticatedRequest(
});
}

const msalAuthOptions = new MSALAuthenticationProviderOptions(scopes);
const msalAuthOptions:AuthCodeMSALBrowserAuthenticationProviderOptions = {
account: authenticationWrapper.getAccount()!,
interactionType: InteractionType.Popup ,
scopes
}
const middlewareOptions = new AuthenticationHandlerOptions(
authProvider,
msalAuthOptions
);
)
const graphRequest = GraphClient.getInstance()
.api(encodeHashCharacters(query))
.middlewareOptions([middlewareOptions])
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/graph-client/graph-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Client } from '@microsoft/microsoft-graph-client';
import 'isomorphic-fetch';
import { authProvider } from './';
import { authProvider } from '.';

export class GraphClient {
private static client: Client;
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/graph-client/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GraphAuthenticationProvider } from './GraphAuthenticationProvider';

export { GraphClient } from './graph-client';
export const authProvider = new GraphAuthenticationProvider();
export const authProvider = new GraphAuthenticationProvider();
2 changes: 1 addition & 1 deletion src/modules/authentication/AuthenticationWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class AuthenticationWrapper implements IAuthenticationWrapper {
return undefined;
}

const allAccounts = msalApplication.getAllAccounts();
const allAccounts: AccountInfo[] = msalApplication.getAllAccounts();
if (!allAccounts || allAccounts.length === 0) {
return undefined;
}
Expand Down

0 comments on commit 9a8652f

Please sign in to comment.