Mobile services on windows azure (part3)


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • COM
  • Mobile services on windows azure (part3)

    1. 1. Mobile ServicesAuthentication and Push Notifications Radu Vunvulea
    2. 2. Who am I? { “name” : “Radu Vunvulea, “company” : “iQuest”, “userType” : “enthusiastic” “technologies” : [ “.NET”, “JS”, “Azure”, “Web”, “Mobile”, “SL” ], “w8experience” : [ “2 LoB App”, “1 Travel App”], “blog” : “”, “email” : ””, “socialMedia” : { “twitter” : “@RaduVunvulea”, “fb” : “radu.vunvulea” } }
    3. 3. Windows Azure Mobile Services• Authentication
    4. 4. Identify providers supported
    5. 5. How to work with data• Define custom scripts that check if the given user id has rights to access his dataApp.MobileService.GetTable<MyEntity>()• Before this we need to create a table with the same name• Update: table.UpdateAsync(entity)• Delete: table.DeleteAsync(entity)• Insert: table.InsertAsync(entity)• Fetch with data: • Where • Take • Skip • OrderBy • Select • ThenBy • ToListAsync
    6. 6. Register your application• Each application need to be register to the identify provider• Windows Live: •• Facebook •• Google •• Twitter •• Every identify provider require to specify the URL of our mobile service
    7. 7. Configure mobile service identity• After configuring the identity provider the “Identity” data need to be configured on our Mobile Service page• We can have more than one identify provider active• All the provider give us similar output: • Key/Id • Secret token• After setting the key and secret token your service is ready to use authentication
    8. 8. Adding authentication to data• Change table permissions of each CRUD operation that you need to be accessible by authenticate user only to “Only Authenticate Users”• After this step all the table content on the given CRUD operation will be accessible only to authenticated users• The error that is returned when a user will try to access a specific service and is not authenticated will be • 401 – Unauthorized
    9. 9. Authentication on the client• There is a build in control that resolve the authentication problem• The only think that we need to do is to specify the identify provider App.MobileService.LoginAsync( MobileServiceAuthenticationProvider.Facebook)• After this step each time when user will access a table from mobile service the user.userId field will contain the user id• Remarks: All users that are login will be able to access any kind of data from our table. In this way we didn’t restrict access to specific rows from it.
    10. 10. Restrict access to table rows• We don’t have an our of the box mechanism• On the INSERT action script we can add a column when we store the user id function insert(item, user, request) { item.userId = user.userId; request.execute(); }• On the action where we want to control access we need to check the userId function read(query, user, request) { query.where({ userId: user.userId }); request.execute(); }
    11. 11. Push notifications • Register your application • Associate your application from VS with your app from Store • Save your Client Secret key and Package Security Identifier from My Apps tab • Add Client Secret key and Package Security Identified to your Mobile Service (under Push tab) • Use “PushNotificationChannelManager” to register to push notifications • Data can be pushed even from CRUD script of Mobile Services tables: push.wns.sendToastText04(, { title: item.text }
    12. 12. Demo
    13. 13. THE END Radu Vunvulea