addon | title | thirdParty | public | url | image | snippets | alias | topics | contentType | useCase | description | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows Azure Mobile Services |
Windows Azure Mobile Services Add-on |
true |
false |
/addons/azure-mobile-services |
/media/platforms/azure.png |
|
|
|
how-to |
integrate-third-party-apps |
Learn how to use Auth0 to authenticate and authorize Windows Azure Mobile Services (WAMS). |
<%= include('../_includes/_uses-delegation') %>
Windows Azure Mobile Services (WAMS) endpoints can be used from anywhere. To configure an app that interacts with WAMS, you can use any of the following tutorials:
The samples that you can download from the Azure Portal are a good starting point.
If you follow the Windows UWP sample (C#), you will end up with an AuthenticateAsync
method that adds one of the standard WAMS authentication mechanisms.
To modify the sample to use Auth0, include this code:
${snippet(meta.snippets.use)}
The important aspects of these lines are:
- The
Auth0Client
class takes 2 parameters: yournamespace
and theclientId
of the application. - There are various overloads for the
LoginAsync
method. In the example above, all options will be presented to the user. You can use other versions ofLoginAsync
to direct login to a specific provider. For example:LoginAsync("github")
will have users login exclusively with GitHub. - The
GetDelegationToken
call exchanges the application token (received in step #2) for another token to be used with WAMS. - The input for the
GetDelegationToken
method is theclientID
of your WAMS enabled app. - A new
MobileServiceUser
object is created with the new information.
The GetDelegationToken
call allows your app to interact with multiple WAMS APIs (or even other APIs). In Auth0, you can control which applications can call which API.
For example, you can login a user with GitHub, then connect them to WAMS and also interact with an AWS hosted endpoint. The delegation call allows you to flow the identity of the user securely across multiple environments.
The final step is to use the information in the token in the server code. Most likely you will have to do the following two things:
- Change permissions on the table for each operation:
- Use the
user
object to change the behavior of the operation.
This example inserts the userId
on new rows:
Then, when querying, it filters out rows for the logged in user: