Why do I see "SyntaxError: Unexpected token p in JSON at position 1" when creating JWT with the Vonage CLI? Why do I see "SyntaxError: Unexpected token p in JSON at position 1" when creating JWT with the Vonage CLI?

Why do I see "SyntaxError: Unexpected token p in JSON at position 1" when creating JWT with the Vonage CLI?

Vonage API Support

Question

Why do I see "SyntaxError: Unexpected token p in JSON at position 1" when creating JWT with the Vonage CLI?

Applies To

  • JWT
  • Vonage CLI version 1.2.4

Answer

Following instructions in Developer Docs and when using Vonage CLI version 1.2.4 on Windows-based PCs, you may need to escape the JSON text fed to this command. For example:

vonage jwt --key_file=./my_sample_app.key --acl='{\"paths\":{\"\/*\/users\/**\":{},\"\/*\/conversations\/**\":{},\"\/*\/sessions\/**\":{},\"\/*\/devices\/**\":{},\"\/*\/image\/**\":{},\"\/*\/media\/**\":{},\"\/*\/applications\/**\":{},\"\/*\/push\/**\":{},\"\/*\/knocking\/**\":{},\"\/*\/legs\/**\":{}}}' --subject=Alice --app_id=MY_APP_ID

Additional Information

This does not appear to happen on macOS systems.