| title | Azure Mobile Services Tutorial | ||||||
|---|---|---|---|---|---|---|---|
| name | Azure Mobile Services | ||||||
| thirdParty | true | ||||||
| image | /media/platforms/azure.png | ||||||
| tags |
|
||||||
| snippets |
|
||||||
| alias |
|
${include('./_thirdPartyApi')}
WAMS endpoints can be used from anywhere. For example: Android, iOS, Windows UWP C#, JavaScript or Windows Phone. You can use any of these tutorials for configuring your app that will interact with WAMS.
A very good starting point is any of the samples you can download from the Azure Portal. Download and follow these:
Changing the samples to use Auth0 is very simple. As an example, if you followed the Windows UWP sample (C#), you will end up with an AuthenticateAsync method that adds one of the standard WAMS authentication mechanisms.
${snippet(meta.snippets.use)}
These 6 new lines of code do all the work for you. The important aspects:
- The
Auth0Clientclass takes 2 parameters: yournamespaceand theclientIdof the client application. - There are various overloads for the
LoginAsyncmethod. In the example above all options will be presented to the user. You can use other versions ofLoginAsyncto direct login to a specific provider. For example:LoginAsync("github")will have users login exclusively with GitHub. - The
GetDelegationTokencall exchanges the client token (just received in step #2) for another token to be used for with WAMS. - A new
MobileServiceUserobject is created with the new information.
The input for the GetDelegationToken method, is the clientID of the App / API where Windows Azure Mobile Services (WAMS) API addon was enable.
You might wonder why step #3 is necessary. This abstraction layer allows your client app to interact with multiple WAMS APIs (or even other APIs altogether). You can control in Auth0 which clients can call which API. You could, as an example, login a user with GitHub, then connect him to WAMS, and also interact with an AWS hosted endpoint. The delegation call allows you to flow the identity of the user across multiple environments in a clean, secure way.
The final step is to use the information on the token on the server code. You will likely have to do 2 things:
This example, inserts the userId on new rows:
And then when querying, it filters out rows for the logged in user:



