Skip to content
This repository was archived by the owner on Aug 2, 2024. It is now read-only.

Commit 928d643

Browse files
committed
Updated for v4.2.0
1 parent c2def10 commit 928d643

File tree

4 files changed

+36
-106
lines changed

4 files changed

+36
-106
lines changed

docs/chapter2/enterprise.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,7 @@ Repeat for each test user you wish to use. Once done, move onto configuring you
4848
Make sure you create the app service in the right directory / subscription. If you have access to more than one directory, you can choose the right one by selecting it under your account drop-down in the top-right corner.
4949

5050
There is also an **Advanced** track. This is used in client-flow situations and in situations where you have more
51-
than one directory. The Express flow is great for getting started quickly.
52-
53-
!!! info "Preview Portal Access"
54-
Azure Active Directory portal access is in preview right now. Certain things can only be done through
55-
the [Azure Classic Portal][classic-portal]. The list of things that cannot be done in the Azure Portal
56-
is thankfully dwindling.
51+
than one directory. It's also used if you want to use the newer MSAL library for authentication. The Express flow is great for getting started quickly.
5752

5853
You can walk through a server-flow authentication to test that you have all the settings correct. Point your browser at https://_yoursite_.azurewebsites.net/.auth/login/aad. The browser will take you through an authentication flow before giving you a successful authentication image:
5954

@@ -193,7 +188,7 @@ Let us take a closer look at this implementation. The `LoginAsync()` method on
193188

194189
Note that we need an extra initialization routine for Android that must be called prior the login provider being
195190
called to pass along the main window of the app (also known as the context). This is done in the `MainActivity.cs`
196-
file **after** the Xamarin Forms initialization call. The dependency service is not set up until after the Xamarin
191+
file **after** the Xamarin Forms initialization call. In addition, Azure Mobile Apps uses Xamarin.Essentials under the covers, and that requires that you handle the callback. The dependency service is not set up until after the Xamarin
197192
Forms library is initialized, so we will not be able to get the login provider reference before that point:
198193

199194
```csharp
@@ -209,10 +204,27 @@ protected override void OnCreate(Bundle bundle)
209204

210205
LoadApplication(new App());
211206
}
207+
208+
protected override void OnResume()
209+
{
210+
base.OnResume();
211+
Xamarin.Essentials.Platform.OnResume();
212+
}
213+
```
214+
215+
iOS is similar, but does not require the initialization step in the main startup class. However, it does require handling the callback in the AppDelegate.cs:
216+
217+
```csharp
218+
public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
219+
{
220+
if (Xamarin.Essentials.Platform.OpenUrl(app, url, options)) {
221+
return true;
222+
}
223+
return base.OpenUrl(app, url, options);
224+
}
212225
```
213226

214-
iOS is similar, but does not require the initialization step in the main startup class. The login provider class
215-
is in `Services\iOSLoginProvider.cs` (in the **TaskList.iOS** project):
227+
The login provider class is in `Services\iOSLoginProvider.cs` (in the **TaskList.iOS** project):
216228

217229
```csharp
218230
using System.Threading.Tasks;

docs/chapter2/social.md

Lines changed: 3 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## Social Authentication
22

3-
Azure App Service provides built-in support for Facebook, Google, Microsoft and Twitter. Irrespective of whether
4-
you intend to use server-flow or client-flow, you will need to configure the Azure App Service Authentication /
5-
Authorization service. The method is pretty similar in each case:
3+
Azure App Service provides built-in support for Facebook and Google. Microsoft and Twitter are also accepted, but Microsoft authentication is handled within the context of Azure Active Directory (and is an option when creating the app registration), and Twitter uses the older (and insecure) OAuth v1 protocol. It should not be used.
4+
5+
Irrespective of whether you intend to use server-flow or client-flow, you will need to configure the Azure App Service Authentication / Authorization service. The method is pretty similar in each case:
66

77
1. Obtain a Developer Account for the provider.
88
2. Create a new application, obtaining a Client ID and Secret.
@@ -146,95 +146,6 @@ If you happen to mis-type the Authorized redirect URI, Google will inform you th
146146
!!! warn
147147
Google has changed the security semantics for its authentication service. You must use the v3.1.0 of the Azure Mobile Apps Client SDK for Server Flow authentication with Google to work.
148148

149-
## Microsoft Account Configuration
150-
151-
The advantage of the Microsoft Account (or MSA, as it is known) is that you already have an account - you need
152-
one for accessing Azure in general. Go to the [Microsoft Account Developer Center][13] and log on with
153-
your Microsoft account. You should use the same one as you use for Azure, but it is not required.
154-
155-
![Microsoft Account Developer Center][img14]
156-
157-
Just to confuse us, there are two **Add an App** buttons. Strangely, they are different. Click the one next to
158-
**Converged applications**.
159-
160-
![MSA: Create an application][img15]
161-
162-
Enter an awesome name, then lick **Create application**.
163-
164-
![MSA: Add a Platform][img16]
165-
166-
Click **Add Platform**, followed by **Web**. In the **Redirect URIs**, enter your app URL +
167-
`/.auth/login/microsoftaccount/callback`. Then Click **Save**.
168-
169-
![MSA: Redirect URI][img17]
170-
171-
Now Click **Generate New Password** under **Application Secrets**.
172-
173-
![MSA: New password][img18]
174-
175-
Unlike the other social providers, this is the only time you will get to see your client secret, so make a note of it or copy and paste it into a notepad. Once you have it copied somewhere, Click **OK**, followed by **Save**.
176-
177-
You now have all the information you need to configure the Microsoft Account section within your App Server
178-
Authentication / Authorization. The Client ID you need to enter is the Application ID and the Client Secret is the
179-
password you just copied somewhere.
180-
181-
![MSA: Configuration of App Service][img19]
182-
183-
Note that you have to choose claims that you want to read. The **wl.basic** and **wl.emails** will give you enough
184-
information to get started with this tutorial.
185-
186-
Click **OK** (at the bottom), followed by **Save** (at the top). You can test the settings by pointing your browser
187-
to https://_yoursite_.azurewebsites.net/.auth/login/microsoftaccount. You will see what should be a normal claims
188-
request page:
189-
190-
![MSA: Claims Request][img20]
191-
192-
Clicking on **Yes** should take you to the normal success page.
193-
194-
## Twitter Configuration
195-
196-
I hope you are seeing that all the OAuth providers take a very similar route to configuring their service. The semantics of the service are slightly different in each case. Twitter is no different. As you might expect, before continuing, sign up for [Twitter][14]. Once you have signed up, the [Twitter Developers Portal][15] is your next stop. Once there, click **Create New App**:
197-
198-
![Twitter: New App][img21]
199-
200-
Most of the fields are self-explanatory. The **Callback URL** is the same thing that the other social providers have
201-
called the Redirect URL. The appropriate value is your app URL + `/.auth/login/twitter/callback`. There is a legal
202-
agreement at the bottom of the page, then you can Click **Create your Twitter application** button.
203-
204-
!!! danger
205-
All social authentication providers have some sort of legal agreement that governs their use. In general, demo or
206-
PoC apps are fair use. However, you should get a legal opinion before using a social authentication provider in a
207-
production app.
208-
209-
Once you have created the app, you will get a tabbed display with all the settings. Click the **Keys and Access
210-
Tokens** tab:
211-
212-
![Twitter: Keys][img22]
213-
214-
Note the values for the **Consumer Key (API Key)** and **Consumer Secret (API Secret)**. They get entered into the
215-
Azure Portal.
216-
217-
!!! warn
218-
There is a check box in the **Settings** tab that says _Allow this application to be used to Sign in with Twitter_.
219-
At the time of writing, this is checked by default. However, if you find you can not log in for some reason, then
220-
ensure this checkbox is checked.
221-
222-
Back in the Azure Portal, select your app service, then **All Settings**, **Authentication / Authorization**, and
223-
finally **Twitter** (assuming you have already turned Authentication on). You can now cut and paste the Consumer
224-
Key and Consumer Secret into the appropriate boxes, before clicking on **OK** (at the bottom) followed by **Save**
225-
(at the top).
226-
227-
As with the other providers, you should test the authentication flow by pointing your browser to
228-
https://_yoursite_.azurewebsites.net/.auth/login/twitter.
229-
230-
![Twitter: Authorize App][img23]
231-
232-
Clicking on **Authorize app** should show you our normal successful authentication screen.
233-
234-
The social authentication providers should now all be configured to handle a web-based or server-flow authentication
235-
request. There are times when configuring a client-flow authentication is different. We will point those out when we
236-
get to them.
237-
238149
## Adding Authentication to a Mobile Client
239150

240151
Now that the backend is completely configured, we can move our attention to the mobile client. We are going to be

docs/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ notifications.
1212
This book does not tell you everything there is to know about either topic. It
1313
focuses on the topics necessary to get your mobile apps connected to the cloud.
1414

15+
> **UPDATE: .NET Client v4.2.0**
16+
>
17+
> In November 2020, Microsoft released v4.2.0 of the .NET Client, which upgraded
18+
> support to .NET Standard 2.0, along with support for the latest versions of the
19+
> iOS and Android operating systems. As a result, some instructions are out of
20+
> date. I'm in progress of updating the documentation to reflect this change.
21+
1522
## What are Cloud Connected Mobile Apps?
1623

1724
I guess I should define some of the terminology that I am going to use. When I

mkdocs.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ site_url: https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure
33
repo_url: https://github.com/adrianhall/develop-mobile-apps-with-csharp-and-azure
44
repo_name: GitHub
55
site_author: Adrian Hall
6-
copyright: 'Copyright © 2017 Adrian Hall'
6+
copyright: 'Copyright © 2017-2020 Adrian Hall'
77
nav:
88
- Getting Started: index.md
99
- Chapter 1 - Introduction:
@@ -65,10 +65,10 @@ extra:
6565
primary: 'red'
6666
accent: 'deep purple'
6767
social:
68-
- type: 'github'
69-
link: 'https://github.com/adrianhall'
70-
- type: 'twitter'
71-
link: 'https://twitter.com/FizzyInTheHall'
68+
- icon: fontawesome/brands/github-alt
69+
link: https://github.com/adrianhall
70+
- icon: fontawesome/brands/twitter
71+
link: https://twitter.com/FizzyInTheHall
7272
markdown_extensions:
7373
- toc:
7474
permalink: true

0 commit comments

Comments
 (0)