Skip to content

Commit 11bdeee

Browse files
committed
add authConfig
1 parent 9fbc78c commit 11bdeee

File tree

9 files changed

+356
-63
lines changed

9 files changed

+356
-63
lines changed

package-lock.json

Lines changed: 153 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
},
1212
"dependencies": {
1313
"@apollo/client": "^3.13.8",
14+
"@azure/msal-browser": "^4.15.0",
15+
"@azure/msal-react": "^3.0.15",
1416
"graphql": "^16.11.0",
1517
"react": "^19.1.0",
16-
"react-dom": "^19.1.0"
18+
"react-dom": "^19.1.0",
19+
"react-router-dom": "^7.7.0"
1720
},
1821
"devDependencies": {
1922
"@eslint/js": "^9.25.0",

src/App.tsx

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,53 @@
1-
import { useState } from 'react'
21
import reactLogo from './assets/react.svg'
32
import viteLogo from '/vite.svg'
43
import './App.css'
54
// Import everything needed to use the `useQuery` hook
6-
import { useQuery, gql } from '@apollo/client';
5+
// import { useQuery, gql } from '@apollo/client';
6+
import { MsalAuthenticationTemplate } from "@azure/msal-react";
7+
import { loginRequest } from "./auth/authConfig";
8+
import { InteractionType } from '@azure/msal-browser';
9+
import { callMsGraph } from "./auth/MsGraph.ts";
710

811
function App() {
9-
const [count, setCount] = useState(0)
10-
const GetEngagements = gql`
11-
query GetEngagements {
12-
engagements {
13-
endCursor
14-
hasNextPage
15-
items {
16-
endDate
17-
id
18-
name
19-
programName
20-
startDate
21-
status
22-
}
23-
}
24-
}
25-
`;
26-
const { loading, error, data } = useQuery(GetEngagements);
27-
if (loading) return <p>Loading...</p>;
28-
if (error) return <p>Error : {error.message}</p>;
12+
// const [count, setCount] = useState(0);
13+
// const [token, setToken] = useState<string>("");
14+
15+
// const { result, error } = useMsalAuthentication(InteractionType.Popup, {
16+
// ...loginRequest,
17+
// redirectUri: "/" // e.g. /redirect
18+
// });
19+
// const navigate = useNavigate();
20+
// const navigationClient = new CustomNavigationClient(navigate);
21+
// msalInstance.setNavigationClient(navigationClient);
22+
23+
// const GetEngagements = gql`
24+
// query GetEngagements {
25+
// engagements {
26+
// endCursor
27+
// hasNextPage
28+
// items {
29+
// endDate
30+
// id
31+
// name
32+
// programName
33+
// startDate
34+
// status
35+
// }
36+
// }
37+
// }
38+
// `;
39+
40+
// const { loading, error, data } = useQuery(GetEngagements);
41+
// if (loading) return <p>Loading...</p>;
42+
// if (error) return <p>Error : {error.message}</p>;
43+
const authRequest = {
44+
...loginRequest
45+
};
2946
return (
30-
<>
47+
<MsalAuthenticationTemplate
48+
interactionType={InteractionType.Redirect}
49+
authenticationRequest={authRequest}
50+
>
3151
<div>
3252
<a href="https://vite.dev" target="_blank">
3353
<img src={viteLogo} className="logo" alt="Vite logo" />
@@ -37,22 +57,13 @@ function App() {
3757
</a>
3858
</div>
3959
<h1>Vite + React</h1>
40-
// Display the data from the query
41-
<ul>
42-
{/* @typescript-eslint/no-explicit-any */},
43-
{data.engagements.items.map((engagement: any) => (
44-
<li key={engagement.id}>
45-
<h2>{engagement.name}</h2>
46-
<p>Program: {engagement.programName}</p>
47-
<p>Status: {engagement.status}</p>
48-
<p>Start Date: {new Date(engagement.startDate).toLocaleDateString()}</p>
49-
<p>End Date: {new Date(engagement.endDate).toLocaleDateString()}</p>
50-
</li>
51-
))}
52-
</ul>
60+
5361
<div className="card">
54-
<button onClick={() => setCount((count) => count + 1)}>
55-
count is {count}
62+
<button onClick={ async () => {
63+
const response = await callMsGraph();
64+
console.log("Response from MS Graph:", response);
65+
}}>
66+
Call MS Graph for testing
5667
</button>
5768
<p>
5869
Edit <code>src/App.tsx</code> and save to test HMR
@@ -61,7 +72,7 @@ function App() {
6172
<p className="read-the-docs">
6273
Click on the Vite and React logos to learn more
6374
</p>
64-
</>
75+
</MsalAuthenticationTemplate>
6576
)
6677
}
6778

0 commit comments

Comments
 (0)