Skip to content

Commit 2e8e8dc

Browse files
authored
Merge pull request #50 from Azure-Samples/omkrishn/iOSAzureSample
Readme and Sample changes.
2 parents 4376abd + f8103ea commit 2e8e8dc

File tree

2 files changed

+45
-64
lines changed

2 files changed

+45
-64
lines changed

MSALiOS/ViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ extension ViewController {
138138

139139
guard let applicationContext = self.applicationContext else { return }
140140
guard let webViewParameters = self.webViewParamaters else { return }
141-
141+
142142
let parameters = MSALInteractiveTokenParameters(scopes: kScopes, webviewParameters: webViewParameters)
143+
parameters.promptType = .selectAccount;
143144

144145
applicationContext.acquireToken(with: parameters) { (result, error) in
145146

README.md

Lines changed: 43 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ urlFragment: ios-ms-graph-api
1212

1313
![Build Badge](https://identitydivision.visualstudio.com/_apis/public/build/definitions/a7934fdd-dcde-4492-a406-7fad6ac00e17/523/badge)
1414

15-
| [Getting Started](https://docs.microsoft.com/azure/active-directory/develop/guidedsetups/active-directory-ios)| [Library](https://github.com/AzureAD/microsoft-authentication-library-for-objc) | [API Reference](https://azuread.github.io/docs/objc/) | [Support](README.md#community-help-and-support)
15+
| [Getting Started](https://docs.microsoft.com/azure/active-directory/develop/guidedsetups/active-directory-ios)| [Library](https://github.com/AzureAD/microsoft-authentication-library-for-objc) | [API Reference](https://azuread.github.io/docs/objc/) | [Support](README.md#feedback,community-help,-and-support)
1616
| --- | --- | --- | --- |
1717

18-
The MSAL library for iOS gives your app the ability to begin using the [Microsoft identity platform](https://aka.ms/aaddev) by supporting [Microsoft Azure Active Directory](https://azure.microsoft.com/services/active-directory/) and [Microsoft Accounts](https://account.microsoft.com/) in a converged experience using industry standard OAuth2 and OpenID Connect. This sample demonstrates all the normal lifecycles your application should experience, including:
18+
The MSAL library for iOS gives your app the ability to begin using the [Microsoft identity platform](https://aka.ms/aaddev) by supporting [Microsoft Azure Active Directory](https://azure.microsoft.com/en-us/services/active-directory/) and [Microsoft Accounts](https://account.microsoft.com) in a converged experience using industry standard OAuth2 and OpenID Connect. This sample demonstrates all the normal lifecycles your application should experience, including:
1919

2020
- How to get a token
2121
- How to refresh a token
@@ -24,7 +24,7 @@ The MSAL library for iOS gives your app the ability to begin using the [Microsof
2424

2525
## Scenario
2626

27-
This app is a multi-tenant app meaning it can be used by any Azure AD tenant or Microsoft Account. It demonstrates how a developer can build apps to connect with enterprise users and access their Azure + O365 data via the Microsoft Graph. During the auth flow, end users will be required to sign in and consent to the permissions of the application, and in some cases may require an admin to consent to the app. The majority of the logic in this sample shows how to auth an end user and make a basic call to the Microsoft Graph.
27+
This app is a multi-tenant app meaning it can be used within any Azure AD tenant and also supports signing in with Microsoft Account. It demonstrates how a developer can build apps to connect with enterprise users and access their Azure + O365 data via the Microsoft Graph. During the auth flow, end users will be required to sign in and consent to the permissions of the application, and in some cases may require an admin to consent to the app. The majority of the logic in this sample shows how to auth an end user and make a basic call to the Microsoft Graph.
2828

2929
![Topology](./images/iosintro.png)
3030

@@ -35,7 +35,9 @@ To run this sample, you'll need:
3535
* Xcode
3636
* An internet connection
3737

38-
## Step 1: Clone or download this repository
38+
## Step 1:
39+
40+
## 1A: Clone or download this repository
3941

4042
From Terminal:
4143

@@ -56,99 +58,77 @@ $ pod install
5658
$ open MSALiOS.xcworkspace
5759
```
5860

59-
## Step 2: (Optional) 1A: Register your App
60-
The app comes pre-configured for testing. If you would like to register your own app, please follow the steps below.
61+
## Step 2: (Optional)
6162

62-
To Register,
63-
1. Sign in to the [Azure portal](https://portal.azure.com) using either a work or school account.
63+
## 2A: Register your App
6464

65-
2. In the left-hand navigation pane, select the **Azure Active Directory** service, and then select **App registrations**
65+
This app comes pre-configured for testing. If you would like to register your own app, please follow the steps below.
6666

67-
3. You will need to have a native client application registered with Microsoft using the [App registrations](https://go.microsoft.com/fwlink/?linkid=2083908) experience.
67+
To Register an app:
68+
69+
1. Sign in to the [Azure portal](https://portal.azure.com) using either a work or school account.
70+
2. In the left-hand navigation pane, select the **Azure Active Directory** blade, and then select **App registrations**.
71+
3. Click on the **New registration** button at the top left of the page.
72+
4. On the app registration page,
73+
- Name your app
74+
- Under **Supported account types**, select **Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)**
75+
- Click **Register** to finish.
76+
5. After the app is created, you'll land on your app management page. Take note of the **Application (client) ID** as this would be needed for the step 2B below.
77+
6. Click **Authentication**, and add new Redirect URI with type **Public client (mobile & desktop)**. Enter redirect URI in format: `msauth.<app_bundle_id>://auth`. Replace <app_bundle_id> with the **Bundle Identifier** for your application.
78+
7. Hit the **Save** button in the top left, to save these updates.
6879

69-
To create an app,
70-
1. Click the **New registration** button on the top left of the page.
71-
2. On the app registration page,
72-
- Name your app
73-
- Under **Supported account types**, select **Accounts in any organizational directory and personal Microsoft accounts**
74-
- Select **Register** to finish.
75-
3. After the app is created, you'll land on your app management page. Click **Authentication**, and add new Redirect URI with type **Public client (mobile & desktop)**. Enter redirect URI in format: `msauth.<app.bundle.id>://auth`. Replace <app.bundle.id> with the **Bundle Identifier** for your application.
76-
4. Hit the **Save** button in the top left, to save these updates.
80+
## 2B: Configure your application
7781

78-
## 1B: Configure your application
82+
1. Update your application's redirect URI scheme in the `Info.plist` file by replacing `msauth.com.microsoft.identitysample.MSALiOS` . Redirect URI scheme follows the format `msauth.[app_bundle_id]`. Make sure to substitue [app_bundle_id] with the **Bundle Identifier** for your application.
7983

80-
1. Add your application's redirect URI scheme to added in the portal to your `info.plist` file. It will be in the format of `msauth.<app.bundle.id>`
8184
```xml
82-
<key>CFBundleURLTypes</key>
85+
<key>CFBundleURLTypes</key>
86+
<array>
87+
<dict>
88+
<key>CFBundleURLSchemes</key>
8389
<array>
84-
<dict>
85-
<key>CFBundleTypeRole</key>
86-
<string>Editor</string>
87-
<key>CFBundleURLName</key>
88-
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
89-
<key>CFBundleURLSchemes</key>
90-
<array>
91-
<string>msauth.<app.bundle.id></string>
92-
</array>
93-
</dict>
90+
<string>msauth.[app_bundle_id]</string>
9491
</array>
92+
</dict>
93+
</array>
9594
```
9695

9796
2. Configure your application defaults
9897

99-
In the `ViewControler.swift` file, update the `kClientID` variable with your client ID.
98+
In the `ViewControler.swift` file, update the `kClientID` variable with your Application (client) ID.
10099

101100
```swift
102-
// Update the below to your client ID you received in the portal. The below is for running the demo only
101+
// Update the client ID below with the one you received in the portal. Below ID is for running the sample app only.
103102

104-
let kClientID = "<your-client-id-here>"
103+
let kClientID = "66855f8a-60cd-445e-a9bb-8cd8eadbd3fa"
105104
```
106105

107106
## Step 3: Run the sample
108107

109-
Click the Run Button in the top menu or go to Product from the menu tab and select Run.
108+
1. Click the Run Button in the top menu or go to Product from the menu tab and click Run.
109+
2. Once the sample app launches, click on the 'Call Microsoft Graph API' button to go through the sign in flow and see the results from Microsoft Graph.
110110

111111
## Feedback, Community Help, and Support
112112

113-
We use [Stack Overflow](http://stackoverflow.com/questions/tagged/msal) with the community to
114-
provide support. We highly recommend you ask your questions on Stack Overflow first and browse
115-
existing issues to see if someone has asked your question before.
113+
We use [Stack Overflow](http://stackoverflow.com/questions/tagged/msal) with the community to provide support. We highly recommend you ask your questions on Stack Overflow first and browse existing issues to see if someone has asked your question before.
116114

117-
If you find and bug or have a feature request, please raise the issue
118-
on [GitHub Issues](../../issues).
115+
If you find a bug or have a feature request, please raise the issue on [GitHub Issues](../../issues).
119116

120-
To provide a recommendation, visit
121-
our [User Voice page](https://feedback.azure.com/forums/169401-azure-active-directory).
117+
To provide a recommendation, visit our [User Voice page](https://feedback.azure.com/forums/169401-azure-active-directory).
122118

123119
## Contribute
124120

125-
We enthusiastically welcome contributions and feedback. You can clone the repo and start
126-
contributing now. Read our [Contribution Guide](Contributing.md) for more information.
121+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
127122

128-
This project has adopted the
129-
[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
130-
For more information see
131-
the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact
132-
[[email protected]](mailto:[email protected]) with any additional questions or comments.
123+
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.
133124

134125
## Security Library
135126

136-
This library controls how users sign-in and access services. We recommend you always take the
137-
latest version of our library in your app when possible. We
138-
use [semantic versioning](http://semver.org) so you can control the risk associated with updating
139-
your app. As an example, always downloading the latest minor version number (e.g. x.*y*.x) ensures
140-
you get the latest security and feature enhanements but our API surface remains the same. You
141-
can always see the latest version and release notes under the Releases tab of GitHub.
127+
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.
142128

143129
## Security Reporting
144130

145-
If you find a security issue with our libraries or services please report it
146-
to [[email protected]](mailto:[email protected]) with as much detail as possible. Your
147-
submission may be eligible for a bounty through the [Microsoft Bounty](http://aka.ms/bugbounty)
148-
program. Please do not post security issues to GitHub Issues or any other public site. We will
149-
contact you shortly upon receiving the information. We encourage you to get notifications of when
150-
security incidents occur by
151-
visiting [this page](https://technet.microsoft.com/en-us/security/dd252948) and subscribing
152-
to Security Advisory Alerts.
131+
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)
132+
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.
153133

154134
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License (the "License");

0 commit comments

Comments
 (0)