You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 10, 2025. It is now read-only.
The MSAL preview library for iOS and macOS gives your app the ability to begin using the [Microsoft Cloud](https://cloud.microsoft.com) by supporting [Azure B2C](https://azure.microsoft.com/en-us/services/active-directory-b2c/) using industry standard OAuth2 and OpenID Connect. This sample demonstrates all the normal lifecycles your application should experience, including:
17
+
The MSAL library for iOS and macOS gives your app the ability to begin using the [Microsoft identity platform](https://aka.ms/aaddev) by supporting [Azure B2C](https://azure.microsoft.com/en-us/services/active-directory-b2c/) using industry standard OAuth2 and OpenID Connect. This sample demonstrates all the normal lifecycles your application should experience, including:
18
18
19
19
* How to get a token
20
20
* How to refresh a token
@@ -25,26 +25,31 @@ The MSAL preview library for iOS and macOS gives your app the ability to begin u
25
25
26
26
```swift
27
27
do {
28
-
// Create an instance of MSALPublicClientApplication with proper config
29
-
let authority =tryMSALB2CAuthority(url: URL(string:kAuthority)!)
30
-
let pcaConfig =MSALPublicClientApplicationConfig(clientId: <your-client-id-here>, redirectUri: nil, authority: authority)
31
-
let application =tryMSALPublicClientApplication(configuration: pcaConfig)
32
-
33
-
application.acquireToken(forScopes: kScopes) { (result, error) in
34
-
DispatchQueue.main.async {
35
-
if result !=nil {
36
-
// Set up your application for the user
37
-
} else {
38
-
print(error)
39
-
}
40
-
}
41
-
}
28
+
// Create an instance of MSALPublicClientApplication with proper config
29
+
let authority =tryMSALB2CAuthority(url: URL(string: "<your-authority-here>")!)
30
+
let pcaConfig =MSALPublicClientApplicationConfig(clientId: "<your-client-id-here>", redirectUri: nil, authority: authority)
31
+
let application =tryMSALPublicClientApplication(configuration: pcaConfig)
32
+
33
+
let viewController =self/*replace with your main presentation controller here */
34
+
let webViewParameters =MSALWebviewParameters(parentViewController: viewController)
35
+
let interactiveParameters =MSALInteractiveTokenParameters(scopes: ["<enter-your-scope-here>"], webviewParameters: webViewParameters)
36
+
37
+
application.acquireToken(with: interactiveParameters) { (result, error) in
38
+
39
+
guardlet result = result else {
40
+
print(error!) /* MSAL token acquisition failed, check error information */
41
+
return
42
+
}
43
+
44
+
let accessToken = result.accessToken
45
+
let account = result.account
46
+
/* MSAL token acquisition succeeded, use access token or check account */
47
+
48
+
}
49
+
}
50
+
catch {
51
+
print(error) /* MSALPublicClientApplication creation failed, check error information */
42
52
}
43
-
44
-
catch {
45
-
print(error)
46
-
}
47
-
}
48
53
```
49
54
50
55
## App Registration
@@ -60,7 +65,7 @@ We use [Carthage](https://github.com/Carthage/Carthage) for package management d
60
65
61
66
1. Install Carthage on your Mac using a download from their website or if using Homebrew `brew install carthage`.
62
67
1. We have already created a `Cartfile` that lists the MSAL library for this project on Github. We use the `/dev` branch.
63
-
1. Run `carthage bootstrap`. This will fetch dependencies into a `Carthage/Checkouts` folder, then build the MSAL library.
68
+
1. Run `carthage bootstrap --platform iOS`. This will fetch dependencies into a `Carthage/Checkouts` folder, then build the MSAL library.
64
69
1. On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop the `MSAL.framework` from the `Carthage/Build` folder on disk.
65
70
1. On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script in which you specify your shell (ex: `/bin/sh`), add the following contents to the script area below the shell:
66
71
@@ -124,9 +129,16 @@ To provide a recommendation, visit our [User Voice page](https://feedback.azure.
124
129
125
130
## Contribute
126
131
127
-
We enthusiastically welcome contributions and feedback. You can clone the repo and start contributing now. Read our [Contribution Guide](Contributing.md) for more information.
132
+
We enthusiastically welcome contributions and feedback. You can clone the repo and start contributing now.
128
133
129
134
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
130
135
136
+
## Security Library
137
+
138
+
This library controls how users sign-in and access services. We recommend you always take the latest version of our library in your app when possible. We use [semantic versioning](http://semver.org) so you can control the risk associated with updating your app. As an example, always downloading the latest minor version number (e.g. x.*y*.x) ensures you get the latest security and feature enhanements but our API surface remains the same. You can always see the latest version and release notes under the Releases tab of GitHub.
139
+
140
+
## Security Reporting
141
+
142
+
If you find a security issue with our libraries or services please report it to [[email protected]](mailto:[email protected]) with as much detail as possible. Your submission may be eligible for a bounty through the [Microsoft Bounty](http://aka.ms/bugbounty) program. Please do not post security issues to GitHub Issues or any other public site. We will contact you shortly upon receiving the information. We encourage you to get notifications of when security incidents occur by visiting [this page](https://technet.microsoft.com/en-us/security/dd252948) and subscribing to Security Advisory Alerts.
131
143
132
144
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License (the "License");
0 commit comments