### Install MSAL with CocoaPods for Browser Authentication Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/README.md Add this to your Podfile to install the MSAL library for browser-delegated authentication using CocoaPods. ```ruby use_frameworks! target 'your-target-here' do pod 'MSAL' end ``` -------------------------------- ### Install CocoaPods Dependency Manager Source: https://github.com/azuread/microsoft-authentication-library-for-objc/wiki/Installation Use this command to install the CocoaPods dependency manager, which is required for managing Swift and Objective-C Cocoa projects. ```bash $ sudo gem install cocoapods ``` -------------------------------- ### Objective-C Error Handling Example Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/CLAUDE.md Demonstrates the correct way to check for errors in Objective-C by verifying the return value before accessing the error variable. This pattern is crucial for robust error management. ```objc - (BOOL)performOperationWithError:(NSError **)error { NSError *internalError = nil; BOOL result = [self doSomethingWithError:&internalError]; if (!result) // Check return value, not error { if (error) *error = internalError; return NO; } return YES; } ``` -------------------------------- ### Add MSAL to Cartfile with Carthage Source: https://github.com/azuread/microsoft-authentication-library-for-objc/wiki/Installation Specify the MSAL repository in your Cartfile to use Carthage for dependency management. This example points to the master branch. ```plaintext github "AzureAD/microsoft-authentication-library-for-objc" "master" ``` -------------------------------- ### Install MSAL with CocoaPods for Native Authentication Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/README.md To enable native authentication capabilities, specify 'MSAL/native-auth' as a subspec in your Podfile. Ensure `use_frameworks!` is also included. ```ruby use_frameworks! target 'your-target-here' do pod 'MSAL/native-auth' end ``` -------------------------------- ### Include MSAL in Podfile with CocoaPods Source: https://github.com/azuread/microsoft-authentication-library-for-objc/wiki/Installation Add this line to your Podfile to include the MSAL library in your target. This is for standard installations. ```ruby target "your-target-here" do pod 'MSAL' end ``` -------------------------------- ### Initialize MSALPublicClientApplication with Configuration Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Use `MSALPublicClientApplicationConfig` to initialize `MSALPublicClientApplication`. This replaces deprecated initializers. ```Objective-C MSALPublicClientApplication *application = [[MSALPublicClientApplication alloc] initWithClientId:@"your-client-id" authority:authority error:nil]; ``` ```Objective-C MSALPublicClientApplicationConfig *config = [[MSALPublicClientApplicationConfig alloc] initWithClientId:@"your-client-id" redirectUri:@"your-redirect-uri" authority:authority]; MSALPublicClientApplication *application = [[MSALPublicClientApplication alloc] initWithConfiguration:config error:nil]; ``` -------------------------------- ### Initialize MSALPublicClientApplication with Configuration (Swift) Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Use `MSALPublicClientApplicationConfig` to initialize `MSALPublicClientApplication` in Swift. This replaces deprecated initializers. ```Swift let config = MSALPublicClientApplicationConfig( clientId: "your-client-id", redirectUri: "your-redirect-uri", authority: authority ) do { let application = try MSALPublicClientApplication(configuration: config) // Use `application` } catch { print("Failed to initialize MSAL: \(error.localizedDescription)") } ``` -------------------------------- ### Initialize MSALPublicClientApplication in Objective-C Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Initialize MSALPublicClientApplication with a configuration object including client ID, redirect URI, and authority. Handle potential initialization errors. ```objc MSALPublicClientApplicationConfig *config = [[MSALPublicClientApplicationConfig alloc] initWithClientId:@"your-client-id" redirectUri:@"msauth.your.bundle.id://auth" authority:authority]; NSError *error = nil; MSALPublicClientApplication *application = [[MSALPublicClientApplication alloc] initWithConfiguration:config error:&error]; if (error) { NSLog(@"Error initializing MSAL: %@", error.localizedDescription); return; } ``` -------------------------------- ### Initialize MSALPublicClientApplication in Swift Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Initialize MSALPublicClientApplication with a configuration object including client ID, redirect URI, and authority. Use a do-catch block to handle potential initialization errors. ```swift let config = MSALPublicClientApplicationConfig(clientId: "your-client-id", redirectUri: "msauth.your.bundle.id://auth", authority: authority) do { let application = try MSALPublicClientApplication(configuration: config) // Proceed with application } catch let error as NSError { print("Error initializing MSAL: \(error.localizedDescription)") } ``` -------------------------------- ### Carthage Copy Frameworks Run Script Source: https://github.com/azuread/microsoft-authentication-library-for-objc/wiki/Installation Add this script to your Xcode project's Build Phases to ensure necessary framework files are copied during the build process, working around an App Store submission bug. ```sh /usr/local/bin/carthage copy-frameworks ``` -------------------------------- ### Add LSApplicationQueriesSchemes to Info.plist Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Include these schemes in your Info.plist under LSApplicationQueriesSchemes to allow MSAL to query for Authenticator and Company Portal. ```xml LSApplicationQueriesSchemes msauthv2 msauthv3 ``` -------------------------------- ### Interactive Acquire Token with Instance-Aware Flow Source: https://github.com/azuread/microsoft-authentication-library-for-objc/wiki/Cloud-instance-discovery-(instance-aware-flow) Pass `instance_aware: true` as an extra query parameter for interactive acquire token calls to enable sovereign cloud discovery. Ensure correct scopes are used for the target sovereign cloud. ```objc NSDictionary *extraQueryParameters = @{@"instance_aware":@"true"}; [application acquireTokenForScopes:kScopes loginHint:nil uiBehavior:MSALUIBehaviorDefault extraQueryParameters:extraQueryParameters completionBlock:^(MSALResult *result, NSError *error) { // Handle result }]; ``` -------------------------------- ### Initialize MSALAuthenticationSchemePop Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/access_token-pop.md Create an instance of MSALAuthenticationSchemePop, specifying the HTTP method and request URL. Nonce and additional parameters are optional. ```objective-c MSALAuthenticationSchemePop *authScheme = [[MSALAuthenticationSchemePop alloc] initWithHttpMethod:MSALHttpMethodPOST requestUrl:requestUrl nonce:nil additionalParameters:nil]; ``` -------------------------------- ### Acquire Token Interactively with Parameters Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Use `acquireTokenWithParameters:` for interactive token acquisition. This replaces deprecated methods. ```Objective-C [application acquireTokenForScopes:@[@"user.read"] completionBlock:^(MSALResult *result, NSError *error) { // Handle result }]; ``` ```Objective-C MSALInteractiveTokenParameters *parameters = [[MSALInteractiveTokenParameters alloc] initWithScopes:@[@"user.read"] webviewParameters:webviewParams]; parameters.promptType = MSALPromptTypeSelectAccount; [application acquireTokenWithParameters:parameters completionBlock:^(MSALResult *result, NSError *error) { // Handle result }]; ``` -------------------------------- ### Create MSALWebviewParameters with Parent View Controller (Objective-C) Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Instantiate MSALWebviewParameters by providing a non-nil UIViewController whose view is attached to a valid window. This is mandatory for interactive token requests in MSAL 2.x. ```objc MSALViewController *viewController = ...; MSALWebviewParameters *webParameters = [[MSALWebviewParameters alloc] initWithAuthPresentationViewController:viewController]; ``` -------------------------------- ### Create MSALWebviewParameters with Parent View Controller (Swift) Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Instantiate MSALWebviewParameters by providing a non-nil UIViewController whose view is attached to a valid window. This is mandatory for interactive token requests in MSAL 2.x. ```swift let viewController = ... // Your UI ViewController let webviewParameters = MSALWebviewParameters(authPresentationViewController: viewController) ``` -------------------------------- ### Pass MSALWebviewParameters to MSALInteractiveTokenParameters (Objective-C) Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Include the created MSALWebviewParameters when initializing MSALInteractiveTokenParameters. This ensures the interactive token request uses the specified presentation context. ```objc MSALInteractiveTokenParameters *parameters = [[MSALInteractiveTokenParameters alloc] initWithScopes:scopes webviewParameters:webParameters]; ``` -------------------------------- ### Acquire Token Interactively with MSAL Objective-C Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/README.md Use this snippet to acquire an access token interactively. Ensure you have a reference to the view controller for presenting the authentication UI and have configured the client ID and scopes. ```obj-c NSError *msalError = nil; MSALPublicClientApplicationConfig *config = [[MSALPublicClientApplicationConfig alloc] initWithClientId:@""]; NSArray *scopes = @[@"your-scope1-here", @"your-scope2-here"]; MSALPublicClientApplication *application = [[MSALPublicClientApplication alloc] initWithConfiguration:config error:&msalError]; MSALViewController *viewController = ...; // Pass a reference to the view controller that should be used when getting a token interactively MSALWebviewParameters *webParameters = [[MSALWebviewParameters alloc] initWithAuthPresentationViewController:viewController]; MSALInteractiveTokenParameters *interactiveParams = [[MSALInteractiveTokenParameters alloc] initWithScopes:scopes webviewParameters:webParameters]; [application acquireTokenWithParameters:interactiveParams completionBlock:^(MSALResult *result, NSError *error) { if (!error) { // You'll want to get the account identifier to retrieve and reuse the account // for later acquireToken calls NSString *accountIdentifier = result.account.identifier; NSString *accessToken = result.accessToken; } else { // Check the error } }]; ``` -------------------------------- ### Acquire Token Interactively with Parameters (Swift) Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Use `acquireToken(with:completionHandler:)` for interactive token acquisition in Swift. This replaces deprecated methods. ```Swift let parameters = MSALInteractiveTokenParameters(scopes: ["user.read"], webviewParameters: webviewParams) parameters.promptType = .selectAccount application.acquireToken(with: parameters) { (result, error) in // Handle result } ``` -------------------------------- ### Migrate Account Retrieval APIs in Swift Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Replaces deprecated account retrieval methods with recommended alternatives. Use `account(forIdentifier:)` for single account retrieval and `accounts(for:)` for fetching multiple accounts. ```Swift do { let account = try application.account(forHomeAccountId: "homeAccountId") // Handle account } catch { print("Failed to get account: \(error)") } let parameters = MSALAccountEnumerationParameters(identifier: identifier) do { let accounts = try application.accounts(for: parameters) // Handle account } catch { print("Failed to retrieve accounts: \(error)") } ``` ```Swift do { let account = try application.account(forIdentifier: "accountId") // Handle account } catch { print("Failed to get account: \(error)") } application.accountsFromDevice { (accounts, error) in // Handle accounts } ``` -------------------------------- ### Configure MSAL for Interactive Token Request with PoP Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/access_token-pop.md Initialize MSALInteractiveTokenParameters for an interactive token acquisition. This requires a UIViewController reference for iOS and provides web view parameters. ```objective-c #if TARGET_OS_IPHONE UIViewController *viewController = ...; // Pass a reference to the view controller that should be used when getting a token interactively MSALWebviewParameters *webParameters = [[MSALWebviewParameters alloc] initWithAuthPresentationViewController:viewController]; #else MSALWebviewParameters *webParameters = [MSALWebviewParameters new]; #endif MSALInteractiveTokenParameters *interactiveParams = [[MSALInteractiveTokenParameters alloc] initWithScopes:scopes webviewParameters:webParameters]; ``` -------------------------------- ### Migrate Account Retrieval APIs in Objective-C Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Replaces deprecated account retrieval methods with recommended alternatives. Use `accountForIdentifier:error:` for single account retrieval and `accountsForParameters:error:` for fetching multiple accounts. ```Objective-C NSError *error = nil; MSALAccount *account = [application accountForHomeAccountId:@"homeAccountId" error:&error]; // Deprecated method to fetch accounts filtered by authority [application allAccountsFilteredByAuthority:^(NSArray *accounts, NSError *error) { // Handle accounts }]; ``` ```Objective-C NSError *error = nil; MSALAccount *account = [application accountForIdentifier:@"accountId" error:&error]; // Recommended synchronous way to fetch accounts MSALAccountEnumerationParameters *parameters = [[MSALAccountEnumerationParameters alloc] initWithIdentifier:identifier]; NSArray *accounts = [application accountsForParameters:parameters error:&error]; if (error) { NSLog(@"Failed to retrieve accounts: %@", error.localizedDescription); } else { // Handle accounts } ``` -------------------------------- ### Pass MSALWebviewParameters to MSALInteractiveTokenParameters (Swift) Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Include the created MSALWebviewParameters when initializing MSALInteractiveTokenParameters. This ensures the interactive token request uses the specified presentation context. ```swift let interactiveParameters = MSALInteractiveTokenParameters(scopes: scopes, webviewParameters: webviewParameters) ``` -------------------------------- ### Configure MSAL for Silent Token Request with PoP Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/access_token-pop.md Initialize MSALSilentTokenParameters for a silent token acquisition. This requires an MSALAccount object obtained previously. ```objective-c NSError *error = nil; MSALAccount *account = [application accountForIdentifier:accountIdentifier error:&error]; if (!account) { // handle error return; } MSALSilentTokenParameters *silentParams = [[MSALSilentTokenParameters alloc] initWithScopes:scopes account:account]; ``` -------------------------------- ### Add MSAL as a Carthage Dependency Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/README.md Include this line in your Cartfile to manage the MSAL dependency using Carthage. ```shell github "AzureAD/microsoft-authentication-library-for-objc" "main" ``` -------------------------------- ### Migrate MSALLogger Configuration in Swift Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Replaces the deprecated singleton-based MSALLogger with the new MSALGlobalConfig.loggerConfig for configuring logging level and callbacks. ```Swift MSALLogger.shared().level = .verbose MSALLogger.shared().setCallback { (level, message, containsPII) in print(message) } ``` ```Swift MSALGlobalConfig.loggerConfig.logLevel = .verbose MSALGlobalConfig.loggerConfig.setLogCallback { (level, message, containsPII) in print(message) } ``` -------------------------------- ### Acquire Token Silently with Parameters Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Use `acquireTokenSilentWithParameters:` for silent token acquisition. This replaces deprecated methods. ```Objective-C [application acquireTokenSilentForScopes:@[@"user.read"] account:account authority:authority completionBlock:^(MSALResult *result, NSError *error) { // Handle result }]; ``` ```Objective-C MSALSilentTokenParameters *params = [[MSALSilentTokenParameters alloc] initWithScopes:@[@"user.read"] account:account]; params.authority = authority; [application acquireTokenSilentWithParameters:params completionBlock:^(MSALResult *result, NSError *error) { // Handle result }]; ``` -------------------------------- ### Include MSAL in Podfile with Git Submodules Source: https://github.com/azuread/microsoft-authentication-library-for-objc/wiki/Installation Use this configuration in your Podfile when checking out a specific branch or tag of MSAL, ensuring submodules are included. ```ruby pod 'MSAL', :git => 'https://github.com/AzureAD/microsoft-authentication-library-for-objc', :branch => 'master', :submodules => true ``` -------------------------------- ### Acquire Token Interactively in Swift Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/README.md Use this snippet to acquire an access token interactively for a user. Ensure you have a reference to the view controller for the webview parameters. The account identifier can be used to retrieve and reuse the account for subsequent token acquisition calls. ```swift let config = MSALPublicClientApplicationConfig(clientId: "") let scopes = ["your-scope1-here", "your-scope2-here"] if let application = try? MSALPublicClientApplication(configuration: config) { let viewController = ... // Pass a reference to the view controller that should be used when getting a token interactively let webviewParameters = MSALWebviewParameters(authPresentationViewController: viewController) let interactiveParameters = MSALInteractiveTokenParameters(scopes: scopes, webviewParameters: webviewParameters) application.acquireToken(with: interactiveParameters, completionBlock: { (result, error) in guard let authResult = result, error == nil else { print(error!.localizedDescription) return } // Get access token from result let accessToken = authResult.accessToken // You'll want to get the account identifier to retrieve and reuse the account for later acquireToken calls let accountIdentifier = authResult.account.identifier }) } else { print("Unable to create application.") } ``` -------------------------------- ### Migrate MSALTelemetry Configuration to MSALTelemetryConfig (Swift) Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Update Swift code to use MSALGlobalConfig.telemetryConfig instead of the deprecated MSALTelemetry singleton for configuring telemetry settings like PII enablement, failure notification, and callbacks. ```Swift MSALTelemetry.sharedInstance().piiEnabled = true MSALTelemetry.sharedInstance().notifyOnFailureOnly = false MSALTelemetry.sharedInstance().telemetryCallback = { event in print(event.name) } ``` ```Swift MSALGlobalConfig.telemetryConfig.piiEnabled = true MSALGlobalConfig.telemetryConfig.notifyOnFailureOnly = false MSALGlobalConfig.telemetryConfig.telemetryCallback = { event in print(event.name) } ``` -------------------------------- ### Migrate MSALLogger Configuration in Objective-C Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Replaces the deprecated singleton-based MSALLogger with the new MSALGlobalConfig.loggerConfig for configuring logging level and callbacks. ```Objective-C [MSALLogger sharedLogger].level = MSALLogLevelVerbose; [[MSALLogger sharedLogger]] setCallback:^ (MSALLogLevel level, NSString *message, BOOL containsPII) { NSLog(@"%@", message); }]; ``` ```Objective-C MSALGlobalConfig.loggerConfig.logLevel = MSALLogLevelVerbose; [MSALGlobalConfig.loggerConfig setLogCallback:^ (MSALLogLevel level, NSString *message, BOOL containsPII) { NSLog(@"%@", message); }]; ``` -------------------------------- ### Configure Authentication Scheme for PoP Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/access_token-pop.md Set the authentication scheme for both interactive and silent token requests to use Proof-of-Possession. ```Objective-C interactiveParams.authenticationScheme = authScheme silentParams.authenticationScheme = authScheme ``` -------------------------------- ### MSAL iOS/macOS Project Structure Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/AGENTS.md Overview of the source code organization within the MSAL iOS/macOS project, detailing the purpose of key directories. ```tree MSAL/src/ ├── public/ # Public API headers (MSAL prefix) │ ├── MSAL.h # Main umbrella header │ ├── ios/ # iOS-specific public headers │ ├── mac/ # macOS-specific public headers │ ├── configuration/ # Configuration classes │ └── native_auth/public/ # Native auth public APIs (Swift) ├── MSALPublicClientApplication.m # Main SDK entry point ├── configuration/ # Internal configuration ├── instance/ # Authority/instance handling ├── native_auth/ # Native authentication (Swift + Obj-C bridge) ├── telemetry/ # Telemetry implementation └── util/ # Utilities ``` -------------------------------- ### Migrate MSALTelemetry Configuration to MSALTelemetryConfig (Objective-C) Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Update Objective-C code to use MSALGlobalConfig.telemetryConfig instead of the deprecated MSALTelemetry singleton for configuring telemetry settings like PII enablement, failure notification, and callbacks. ```Objective-C [MSALTelemetry sharedInstance].piiEnabled = YES; [MSALTelemetry sharedInstance].notifyOnFailureOnly = NO; [[MSALTelemetry sharedInstance] setTelemetryCallback:^(MSALTelemetryEvent *event) { NSLog(@"%@", event.name); }]; ``` ```Objective-C MSALGlobalConfig.telemetryConfig.piiEnabled = YES; MSALGlobalConfig.telemetryConfig.notifyOnFailureOnly = NO; MSALGlobalConfig.telemetryConfig.telemetryCallback = ^(MSALTelemetryEvent *event) { NSLog(@"%@", event.name); }; ``` -------------------------------- ### Clone MSAL Repository Manually Source: https://github.com/azuread/microsoft-authentication-library-for-objc/wiki/Installation Clone the MSAL repository using Git. Ensure you include the --recursive flag to also clone submodules. ```bash git clone https://github.com/AzureAD/microsoft-authentication-library-for-objc.git --recursive ``` -------------------------------- ### Add MSAL Git Submodule Source: https://github.com/azuread/microsoft-authentication-library-for-objc/wiki/Installation Include MSAL as a Git submodule in your project. This involves adding the submodule, checking out a specific tag, and committing the changes. ```bash git submodule add https://github.com/AzureAD/microsoft-authentication-library-for-objc msal cd msal git checkout tags/ git submodule update --init --recursive cd .. git add msal git commit -m "Use MSAL git submodule at " git push ``` -------------------------------- ### Acquire Token Silently with Parameters (Swift) Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Use `acquireTokenSilent(with:completionHandler:)` for silent token acquisition in Swift. This replaces deprecated methods. ```Swift let parameters = MSALSilentTokenParameters(scopes: ["user.read"], account: account) parameters.authority = authority application.acquireTokenSilent(with: parameters) { (result, error) in // Handle result } ``` -------------------------------- ### Update Info.plist for MSAL Redirect URI Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md Add this XML entry to your app's Info.plist to register the MSAL redirect URI scheme. ```xml CFBundleURLTypes CFBundleURLSchemes msauth.your.bundle.id ``` -------------------------------- ### MSALResult Properties for PoP Tokens Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/access_token-pop.md Understand the `authorizationHeader` and `authenticationScheme` properties of `MSALResult` when dealing with PoP protected resources. The `authorizationHeader` contains the Signed HTTP Request (SHR). ```Objective-C /** The authorization header for the specific authentication scheme . For instance "Bearer ..." or "Pop ...". For pop resource, this value is the Signed Http Request (SHR) as explained in step 4 which is sent to the resource provided to access the resource */ @property (readonly, nonnull) NSString *authorizationHeader; /** The authentication scheme for the tokens issued. For instance "Bearer " or "Pop". */ @property (readonly, nonnull) NSString *authenticationScheme; ``` -------------------------------- ### Default Authentication Scheme in MSALTokenParameters Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/access_token-pop.md Illustrates that the default authentication scheme for MSALTokenParameters is MSALAuthenticationSchemeBearer, initialized automatically. ```objective-c @implementation MSALTokenParameters - (instancetype)initWithScopes:(NSArray *)scopes { self = [super init]; if (self) { _scopes = scopes; _authenticationScheme = [MSALAuthenticationSchemeBearer new]; } return self; } ``` -------------------------------- ### Swift Safe Unwrap of Account Properties Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/MSAL_2x_Migration_Guide.md When accessing account properties like homeAccountId, tenantProfiles, and isSSOAccount in Swift, safe unwrapping is required due to their optional declaration in the MSALAccount protocol. This ensures proper handling of potential nil values. ```swift if let homeAccountId = account.homeAccountId { // Use homeAccountId.identifier } ``` ```swift guard let tenantProfiles = account.tenantProfiles else { // Handle missing tenant profiles return } ``` ```swift if account.isSSOAccount { // Proceed with SSO-specific logic } ``` -------------------------------- ### Add Specific MSAL Version to Cartfile with Carthage Source: https://github.com/azuread/microsoft-authentication-library-for-objc/wiki/Installation To use a particular version of MSAL with Carthage, specify the version number instead of the branch name in your Cartfile. ```plaintext github "AzureAD/microsoft-authentication-library-for-objc" == ``` -------------------------------- ### Update LSApplicationQueriesSchemes for iOS 13 Support Source: https://github.com/azuread/microsoft-authentication-library-for-objc/wiki/iOS-13-and-macOS-10.15-support-in-MSAL Add these schemes to your app's Info.plist to detect the presence of the latest Authenticator app on devices running iOS 13. ```plist LSApplicationQueriesSchemes msauthv2 msauthv3 ``` -------------------------------- ### MSALAuthenticationSchemeProtocol Property Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/access_token-pop.md The MSALTokenParameters class includes an 'authenticationScheme' property to specify the authentication method. MSALAuthenticationSchemeBearer is the default. ```objective-c /** Authentication Scheme to access the resource */ @property (nonatomic, nullable) id authenticationScheme; ``` -------------------------------- ### MSALHttpMethod Enum Definition Source: https://github.com/azuread/microsoft-authentication-library-for-objc/blob/dev/docs/access_token-pop.md Defines the possible HTTP methods that can be used with MSALAuthenticationSchemePop. ```objective-c typedef NS_ENUM(NSUInteger, MSALHttpMethod) { /* Http Method for the pop resource */ MSALHttpMethodGET, MSALHttpMethodHEAD, MSALHttpMethodPOST, MSALHttpMethodPUT, MSALHttpMethodDELETE, MSALHttpMethodCONNECT, MSALHttpMethodOPTIONS, MSALHttpMethodTRACE, MSALHttpMethodPATCH }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.