Skip to content

Exposing DynamoDb data as an OData endpoint and consuming it on WinPhone Sample

scale-tone edited this page Apr 16, 2017 · 1 revision

MobileNotes.Web is an ASP.Net Web Application, that demonstrates the following:

  • How to define a (cached) OData-enabled Linq2DynamoDb.DataContext.
  • How to expose it as an OData endpoint.
  • How to restrict accesss to that OData endpoint only to users authenticated with Microsoft Account.
  • How to disallow a user to see other user's DynamoDb entities.

The user's OAuth 2.0 authentication token should be passed to the data service via the HTTP Authorization header. Then, on each request the token is parsed and validated using the JsonWebToken utility from LiveSDK samples. Then the UserId is taken from the token's claims and is used as a hash key in the DynamoDb MobileNotes table. So, this is how we get a-kind-of-Azure Mobile Services in AWS :)

Note, that user data and queries are cached. This might be particularly important for a mobile application, because it's usually difficult to predict the load (number of requests per second) from mobile devices. And without caching, because of DynamoDb's throttling, just a small mistake in setting table capacities can make your service unavailable for a long time.

MobileNotes.WinPhoneApp is Windows Phone 8 Application, that demonstrates the following:

After the user enters her Microsoft Account credentials, she is able to view, add and remove her notes. Checking/unchecking the "Show Notes for the last day only" checkbox demonstrates LINQ query generation on the client (which is then passed to the service and then translated to DynamoDb Query operation).

Don't forget to put your own application credentials here! You would need to register your app on https://account.live.com/developers/applications to obtain them.