pubnub / javascript

PubNub JavaScript SDK docs https://www.pubnub.com/docs/sdks/javascript
Other
553 stars 401 forks source link

PNBadRequestCategory when using grantToken after an upgrade from v7 to v8 of the API #373

Closed SpaseESG closed 6 months ago

SpaseESG commented 6 months ago

After upgrading to v8 it kept failing with a bogus reason (tried both 8.0.1 and 8.1.0), for now I've downgraded to 7.6.1 and the issue is resolved.

Full error:

{
    "status": {
        "error": true,
        "category": "PNBadRequestCategory",
        "operation": "PNAccessManagerGrantToken",
        "statusCode": 400,
        "errorData": {
            "error": {
                "message": "Invalid JSON",
                "source": "grant",
                "details": [
                    {
                        "message": "Content-Type must be `application/json`.",
                        "location": "<root>",
                        "locationType": "body"
                    }
                ]
            },
            "service": "Access Manager",
            "status": 400
        }
    },
    "name": "PubNubError"
}

Code that is being used:

const token = pubNub({ userId }).grantToken({
        ttl: 15,

        patterns: {
            channels: channels,
        },
    });
pubnub-release-bot commented 6 months ago

@SpaseESG this issue is addressed in v8.2.0