I am building a phone app using Cordova/Phonegap and an Azure Mobile Services backend. I need to use a custom authenticator since this is integrating with a current software product.
I built the server side using info from http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-get-started-custom-authentication/
I set config.SetIsHosted(true);
in WebApiConfig
From the client, I seem to be authenticating fine and getting back a valid token, but I'm not sure what to do with it. I've tried setting client.currentUser
, but my api calls are coming back as unauthorized.
Here's some code:
client = new WindowsAzure.MobileServiceClient("http://`localhost`:50523");
login = function () {
client.invokeApi("CustomLogin", {
method: "post",
body: { "username": "user1", "password": "pass1" }
})
.done(function (result) {
var login = JSON.parse(result.response);
client.currentUser = login.user;
client.currentUser.mobileServiceAuthenticationToken = login.authenticationToken;
//lets try now that i'm valid
getMembers();
app.navigate("views/home.html");
}, function(error) {
alert(error);
});
};
getMembers = function () {
client.invokeApi("Member", {
method: "get",
body: {}
})
.done(
function(result) {
alert(result.result[0].lName);
},
function(error) {
alert(error);
});
};
Is there more I need to do with the authentication token to make this work? Thanks!
EDIT: Some more info --
Using Fiddler to monitor the traffic, I see that the call to /api/member
has a few headers set:
X-ZUMO-AUTH: set to the token I got back earlier
X-ZUMO-FEATURES: AJ
X-ZUMO-INSTALLATION-ID: a guid
X-ZUMO-VERSION: ZUMO/1.2(...)