Skip to content

Error: invalid expiresIn,jwtid option for number payload #326

Description

@weyert

I am trying to use the latest version of the module only I keep getting issues when trying to sign a token with the expiresIn and jwtid-ptions. Only keep getting the same error (see below) keeps complaining about number payload but why? The documents seem to suggest it can be a string. What am I doing wrong?

Error: invalid expiresIn,jwtid option for number payload
    at Object.module.exports [as sign] (/Users/Development/Projects/xyz/backend/node_modules/jsonwebtoken/sign.js:81:22)

I am using the following code:

    return jwt.sign(
        payload,            // This is the payload we want to put inside the token
        process.env.TOKEN_SECRET || "oursecret", // Secret string which will be used to sign the token,
        {
            expiresIn: '2h', // let the token expire after 2 hours of creation
            jwtid: identifier, // unique identifier (uuid.v4())
        }
    );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions