Skip to content

Commit 4818005

Browse files
committed
Update auth step for new scopes
Also added code to save user's time zone and time format.
1 parent 4e6b40b commit 4818005

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

demo/graph-tutorial/src/AuthProvider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ export default function withAuthProvider<T extends React.Component<AuthComponent
133133
isAuthenticated: true,
134134
user: {
135135
displayName: user.displayName,
136-
email: user.mail || user.userPrincipalName
136+
email: user.mail || user.userPrincipalName,
137+
timeZone: user.mailboxSettings.timeZone,
138+
timeFormat: user.mailboxSettings.timeFormat
137139
},
138140
error: null
139141
});

demo/graph-tutorial/src/Config.ts.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export const config = {
33
redirectUri: 'http://localhost:3000',
44
scopes: [
55
'user.read',
6-
'calendars.read'
6+
'mailboxsettings.read',
7+
'calendars.readwrite'
78
]
89
};

demo/graph-tutorial/src/GraphService.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ function getAuthenticatedClient(accessToken: string) {
2020
export async function getUserDetails(accessToken: string) {
2121
const client = getAuthenticatedClient(accessToken);
2222

23-
const user = await client.api('/me').get();
23+
const user = await client
24+
.api('/me')
25+
.select('displayName,mail,mailboxSettings,userPrincipalName')
26+
.get();
27+
28+
console.log(JSON.stringify(user));
2429
return user;
2530
}
2631
// </graphServiceSnippet1>

tutorial/04-add-aad-auth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ In this section you will get the user's details from Microsoft Graph.
234234

235235
1. Replace the existing `getUserProfile` function with the following code.
236236

237-
:::code language="typescript" source="../demo/graph-tutorial/src/AuthProvider.tsx" id="getUserProfileSnippet" highlight="6-15":::
237+
:::code language="typescript" source="../demo/graph-tutorial/src/AuthProvider.tsx" id="getUserProfileSnippet" highlight="6-18":::
238238

239239
1. Save your changes and start the app, after sign-in you should end up back on the home page, but the UI should change to indicate that you are signed-in.
240240

0 commit comments

Comments
 (0)