Curyous
Curyous

Reputation: 8866

How do you get the username of a Windows Azure Mobile Services user?

Once a user has authenticated, how do I get the username of their account? I couldn't see anything in MSUser.h that would help. Do I have to do it differently for each of the 4 different identity providers?

Upvotes: 4

Views: 1278

Answers (1)

conradj
conradj

Reputation: 2610

Do you mean on the client or server side? In server code, you can use getIdentities() on the user object that is always a parameter in the server scripts. The properties are different for each of the providers, as follows:

{ 
    "facebook":{ 
        "userId":"Facebook:my-actual-user-id", 
        "accessToken":"the-actual-access-token" 
    } 
}

And for Twitter:

{ 
    "twitter":{ 
        "userId":"Twitter:my-actual-user-id", 
        "accessToken":"the-actual-access-token", 
        "accessTokenSecret":"the-actual-access-token-secret" 
    } 
} 

Microsoft:

{ 
    "microsoft":{ 
        "userId":"MicrosoftAccount:my-actual-user-id", 
        "accessToken":"the-actual-access-token" 
    } 
} 

Google:

{ 
    "google":{ 
        "userId":"Google:my-actual-user-id", 
        "accessToken":"the-actual-access-token" 
    } 
}

(Taken from Carlos Figueira's excellent blog post which goes into more detail)

On the client side, I haven't used the iOS SDK, but in JavaScript it is client.currentUser.userId

Upvotes: 3

Related Questions