George Edwards George Edwards - 5 months ago 36
Node.js Question

Setting jwt audience in Azure Mobile Apps backend

I am playing with an Azure Mobile Apps backend (nodeJS), as discussed here. I have been using the default web setup configuration to develop my mobile app, but now I want to customise the cloud backend functionality, so I have created a local backend with the Azure-Mobile-Apps SDK.

I logged in with my mobile app (using the authorization aspect of the Azure client SDK) and then captured the AuthToken, using a live managed backend setup.

When I then come to try and authorise a request, I get the following issue:


{ "name": "JsonWebTokenError", "message": "jwt audience invalid. expected: urn:microsoft:windows-azure:zumo" }


Following on from: Locally Testing Azure Mobile Auth - invalid jwt signature

How can I set the jwt audience?

Answer

To set the audience and issuer, use the auth:{} object in your azureMobile.js. You can decode the JWT at jwt.io to see what the audience and issuer are, then do:

auth: {
    audience: '<your audience>',
    issuer: '<your issuer>'
};

Some good references: