销售电话: 1-800-867-1380

 none
The best way to generate a blob storage container name for each user on WP7

    问题

  • I have been playing around with the Windows Azure Toolkit for Windows Phone 7 for a few days so I am still very new but learning quickly. I have an app idea I would like to develop but I have ran into an problem.

    The app would allow a user(s) to log in using ACS and if it is their first time using the app, they would have to register their name and email just like the template for the WAT for WP7 does. After the user has logged in I want to create a private container using a generated name based on their log in details.

    I know that Windows Live ID does not allow for Email Address to be accessed using the claims(?) but Google and Yahoo do. I was thinking about basing the container name off their email address but since Windows Live does not allow to access this I am stumped.

    I do not want to store this information on the users phone because if the user gets a new phone, they will not have this information.

    What would be the best way to handle this?

    If you need more details let me know and I will do the best I can.

    Thanks in advanced.

    2012年4月11日 2:34

答案

  • Hi,

    If you can get formatted string for Windows Live ID by that property, it's looks good to get different user infor via these two ways. If you want to enable Live Connect and ACS, you need to handle two sets of authentication way in your application, Live Connect for Windows Live ID and ACS for Google and Yahoo!. So i think the former method is better - if you can really get nice string from UserIdentifier property.

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    2012年4月12日 10:27
  • Hi,

    I am not 100% sure, but i do not find any out-of-box method or tool to generate Blob container name automatically, i suggest you create a method by yourself, for example, generate name base on user's email address, and remove unallowed characters, convert name to lower, check the container if exists and generate some recommended names to users via regular expression.

    Blob Container name rules:

    • Container names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character.
    • Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in container names.
    • All letters in a container name must be lowercase.
    • Container names must be from 3 through 63 characters long.

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework


    2012年4月11日 6:10

全部回复

  • Hi,

    I am not 100% sure, but i do not find any out-of-box method or tool to generate Blob container name automatically, i suggest you create a method by yourself, for example, generate name base on user's email address, and remove unallowed characters, convert name to lower, check the container if exists and generate some recommended names to users via regular expression.

    Blob Container name rules:

    • Container names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character.
    • Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in container names.
    • All letters in a container name must be lowercase.
    • Container names must be from 3 through 63 characters long.

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework


    2012年4月11日 6:10
  • Hi Arwind,

    My first approach was to do exactly that, but if the user logs in using their Windows Live ID I am unable to get their email address after they have registered.

    When you create a new WAT for WP7 project and open up RegisterPage.xaml.cs, the first code you will see is this.

    	private const string NameClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name";
            private const string EmailClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress";
    
            public RegisterPage()
            {
                this.InitializeComponent();
    
                this.ViewModel = new RegisterPageViewModel();
                var items = PhoneHelpers.ParseQueryString(App.CloudClientFactory.TokenStore.SecurityToken);
                var claimsUserName = items[System.Net.HttpUtility.UrlEncode(NameClaimType)];
                var claimsEmail = items[System.Net.HttpUtility.UrlEncode(EmailClaimType)];
                this.ViewModel.UserName = string.IsNullOrWhiteSpace(claimsUserName) ? string.Empty : claimsUserName;
                this.ViewModel.EMail = string.IsNullOrWhiteSpace(claimsEmail) ? string.Empty : claimsEmail;
            }

    Now if I try to do this exact thing in for example the MainPage.xaml.cs and create a new view model for username and email I am unable to get the users email. 

    This is what I have noticed

    New User:

    START > Login Page > (check registration) > Register Page > Main Page

    Returning User:

    START > Login Page > (check registration) > Main Page

    If you are a new user on the app and you go to the register page, the 2 fields that are provided will be automatically filled in even if the user signs in with their Windows Live ID. I could take that email value from there and store it into isolated storage but if the user gets a new phone or uninstalls the app they would skip the registration part after they logged in because they would already be registered.

    I was thinking of asking the user to provide their email again but that would be 3 times in the first 3 pages to even get into the application.

    2012年4月11日 6:49
  • Hi,

    You're right. You cant get Live ID and e-mail address via ACS, not just Widnows Phone application, other types application also cant get these info. I suggest you consider use Live Connect, Live Connect can get Live ID and Email address, then you can create yourself method to generate Blob container name.

    Live Connect documentation:

    http://msdn.microsoft.com/en-us/windowslive/ff519582

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    2012年4月11日 9:23
  • I see how to get that info with Live Connect.

    So should I just ditch the whole ACS log in all together? 

    If I do will the users still be able to connect to the blob storage without going through the registration process that the toolkit template sets up for ACS?

    2012年4月11日 22:22
  • Hi,

    No, i mean you can make a choice for users, the ACS can supports multiple identity providers, we can add Live Connect as the IDP of ACS, so the different users can choose the login way to access Blob storage, Windows Live users use Live Connect, other users use ACS with specifical Idp.

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    2012年4月12日 2:08
  • I searched the internet for a bit looking on how to do this but I could not find anything. I do not even know where to begin.

    I noticed that if I return

    App.CloudClientFactory.UserIdentifier.ToString();

    I get a nice formatted string for the Windows Live ID, but nasty long strings for Google and Yahoo. 

    What I am thinking, if its possible to check if the user logged in using Windows Live, Google or Yahoo and depending if they logged in using Windows Live, use that UserIdentifier string as the container name and use their email for Google and Yahoo log in.

    Any thoughts on that?

    2012年4月12日 4:44
  • Hi,

    If you can get formatted string for Windows Live ID by that property, it's looks good to get different user infor via these two ways. If you want to enable Live Connect and ACS, you need to handle two sets of authentication way in your application, Live Connect for Windows Live ID and ACS for Google and Yahoo!. So i think the former method is better - if you can really get nice string from UserIdentifier property.

    Hope this helps.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    2012年4月12日 10:27