diff --git a/.gitignore b/.gitignore index 99a447b84f..c3defe02ad 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ config.js ### jsdoc dir ### docs + +### ide / editors ### +.vscode \ No newline at end of file diff --git a/lib/jwt/AccessToken.js b/lib/jwt/AccessToken.js index bd72de4e15..e6a4f7e28d 100644 --- a/lib/jwt/AccessToken.js +++ b/lib/jwt/AccessToken.js @@ -249,7 +249,7 @@ _.extend(AccessToken.prototype, { } var grants = {}; - if (_.isString(this.identity)) { grants.identity = this.identity; } + if (_.isInteger(this.identity) || _.isString(this.identity)) { grants.identity = String(this.identity); } _.each(this.grants, function(grant) { grants[grant.key] = grant.toPayload(); diff --git a/spec/unit/jwt/AccessToken.spec.js b/spec/unit/jwt/AccessToken.spec.js index 1006828de2..fe14f7e1ae 100644 --- a/spec/unit/jwt/AccessToken.spec.js +++ b/spec/unit/jwt/AccessToken.spec.js @@ -28,6 +28,11 @@ describe('AccessToken', function() { it('should require secret', function() { expect(initWithoutIndex(2)).toThrow(new Error('secret is required')); }); + it('should convert identity from integer to string', function () { + var token = new twilio.jwt.AccessToken(accountSid, keySid, 'secret', { identity: 4444 }); + var decoded = jwt.decode(token.toJwt()); + expect(decoded.grants.identity).toEqual('4444'); + }); }); describe('generate', function() {