Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 7203d58

Browse files
author
Trwalke
committed
Update android specific steps
1 parent 92e7b65 commit 7203d58

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,18 @@ If the attempt to obtain a token silently fails, we do nothing and display the s
164164
When the sign in button is pressed, we execute the same logic - but using a method that shows interactive UX:
165165

166166
```csharp
167+
var windowLocatorService = DependencyService.Get<IParentWindowLocatorService>();
168+
167169
AuthenticationResult ar = await App.PCA.AcquireTokenInteractive(App.Scopes)
168170
.WithAccount(GetUserByPolicy(App.PCA.Users,
169171
App.PolicySignUpSignIn)
170-
.WithParentActivityOrWindow(App.ParentActivityOrWindow)
172+
.WithParentActivityOrWindow(() => windowLocatorService?.GetCurrentParentWindow()))
171173
.ExecuteAsync();
172174
```
173175

174176
The `Scopes` parameter indicates the permissions the application needs to gain access to the data requested through subsequent web API call (in this sample, encapsulated in `OnCallApi`). Scopes should be input in the following format: `https://{tenant_name}.onmicrosoft.com/{app_name}/{scope_value}`
175177

176-
The `.WithParentActivityOrWindow()` is used in Android to tie the authentication flow to the current activity, and is ignored on all other platforms. For more platform specific considerations, please see below.
178+
The `.WithParentActivityOrWindow()` is used in Android to tie the authentication flow to the current activity, and is ignored on all other platforms. That code ensures that the authentication flows occur in the context of the current activity.
177179

178180
The sign out logic is very simple. In this sample we have just one user, however we are demonstrating a more generic sign out logic that you can apply if you have multiple concurrent users and you want to clear up the entire cache.
179181

@@ -189,7 +191,7 @@ foreach (var account in accounts.ToArray())
189191

190192
The platform specific projects require only a couple of extra lines to accommodate for individual platform differences.
191193

192-
UserDetailsClient.Droid requires two extra lines in the `MainActivity.cs` file.
194+
UserDetailsClient.Droid requires one extra line in the `MainActivity.cs` file.
193195
In `OnActivityResult`, we need to add
194196

195197
```csharp
@@ -198,14 +200,6 @@ AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestC
198200
```
199201
That line ensures that control goes back to MSAL once the interactive portion of the authentication flow ended.
200202

201-
In `OnCreate`, we need to add the following assignment:
202-
203-
```csharp
204-
App.ParentActivityOrWindow = this; // This activity
205-
```
206-
207-
That code ensures that the authentication flows occur in the context of the current activity.
208-
209203
### iOS specific considerations
210204

211205
UserDetailsClient.iOS only requires one extra line, in AppDelegate.cs.

0 commit comments

Comments
 (0)