[Node.js][Mobile Apps] Custom domain error with getIdenity() RRS feed

  • Question

  • I'm using a node backend for the app service and configured a custom domain versus the default 

    I created a simple custom api which worked fine. I then tried to have the api retrieve the user information and the call to ./auth/me was failing with a 401 error. I noticed in the logs that the host in the ./auth/me was versus the custom domain which had been used to issue the access token.

    var api = {
         get: function (req, res, next) {
         	req.azureMobile.user.getIdentity().then(function (data) {
         	}).catch(function (error) {
     module.exports = api;

    I dropped the custom domain and everything is working and retrieving the user info as desired, but is there anyway to use a custom domain and use getIdentity() properly?

    Monday, June 13, 2016 8:48 PM

All replies

  • How you call the ./auth/me? I am sorry I cannot understand your requirement very clearly. Could you clarify your conceived workflow?
    Tuesday, June 14, 2016 8:09 AM
  • I posted the code I was using in the initial post. I'm using the getIdentity() function in the SDK which calls .auth/me.

    What I am trying to do is gather more information about the logged in user (name, email, AD Security groups) than is found on the claims on the logged in user. From reading, I found that calling getIdentity() is the way to get more info on the user.

    I have configured a custom domain for my app service.

    Here is the code from getIdentity.js in the azure-mobile-apps-node-sdk which is calling / It seems that the endpoint.hostname is returning as versus my configured, which is causing the 401 error. In the meantime, I stopped using the custom domain in Azure AD, and everything works fine.

    module.exports = function (authConfiguration, token, provider) {
        var endpoint = url.parse(authConfiguration.issuer);
        return promises.create(function (resolve, reject) {
            var requestOptions = {
                hostname: endpoint.hostname,
                port: endpoint.port || 443,
                path: '/.auth/me' + (provider ? '?provider=' + provider : ''),
                method: 'GET',
                headers: {
                    'x-zumo-auth': token
            log.silly('GetIdentity Request: ', requestOptions);
            var request = https.request(requestOptions, function (response) {
               log.silly('GetIdentity Response Code: ', response.statusCode);
               var responseData = '';
               response.on('data', function (chunk) {
                   responseData += chunk;
               response.on('end', function () {
                   log.silly('GetIdentity Response: ', responseData);
                   var responseObj = normalizeClaims(JSON.parse(responseData));
            request.on('error', function (error) {
                log.silly('Could not retrieve identity: ', error);

    Tuesday, June 14, 2016 11:11 PM