I’m writing an authentication application in Next Js (v12.2.5). The application also uses React (v18.2.0). The problem is with persisting the authentication state. When the browser is refreshed, the login session is killed. Why is this happening even though I am getting and setting the token in the local storage. I would like to persist the login session to survive
Tag: jwt
How to deal with a TokenExpiredError: jwt expired?
I have a project with NodeJS with jwt for managing user authentication. After a period of time, my app stops working and my server prints the following: Now, the person who was working in this project before me had this code for managing the tokens: My guess is that the issue is the expiresIn: ‘7d’ (since I’m quite new with
Validating Firebase Auth tokens manually
I’m trying to use cloudflare workers to perform authenticated actions. I’m using firebase for authentication and have access to the Access Tokens coming through but since firebase-admin uses nodejs modules it can’t work on the platform so i’m left manually validating the token. I’ve been attempting to authenticate with the Crypto API and finally got it to import the public
How to retrieve Token for API calls in cypress
Due to a lack of knowledge in JS, I do face with below problem. I do automation testing with cypress and for external API endpoints, I need to use Dynamic Token that expires every 3600 secs. I did some short research and find out that, for reaching to JWT Token I will need 1st SSO login (that my app has).
Cannot verify JWT – UnhandledPromiseRejectionWarning: JsonWebTokenError: jwt malformed
I have function that just send data to database (my posts). I use private and public keys to sign and verify tokens. I can send this token in header from front-end to back-end, but has problem with verifying it. Here is how this flow looks like: Front-end Back-end Middleware auth And JWT service The problem starts after getUserPromise function. This
How to verify a JWT signature using Node-jose
I am trying to use node-jose to verify signatures of my JWTs. I know the secret, but am having trouble converting this secret into a JWK used for the verification. Here is an example of how I am trying to create my key with my secret and verify my token. This results in Error: no key found. Do I need
Add generating headers method to route creating method [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago. Improve this question I need an advice how to make my code better. I have a simple class that gets data from backend that
Convert AWS KMS ECDSA_SHA_256 Signature from DER encoded ANS.1 format to JWT base64url encoded R || S format in NodeJS/Javascript
I am trying to create JWT Signature in NodeJS with ES256 algorithm using AWS KMS Customer Managed Keys. The signature created using AWS KMS with cryptographic Signing Algorithms ECDSA_SHA_256 is not JWT accepted R || S format. As per AWS doc, Signature will be in DER encoded ANS X9.62–2005 format (https://docs.aws.amazon.com/kms/latest/APIReference/API_Sign.html#API_Sign_ResponseSyntax). I tried to convert the AWS KMS Sign to
Creating Compressed JWT Payload in JavaScript
I have a function which parses a compressed JWT Payload into JSON. It makes sense to me the way the function works. I want to create a function that can do the exact opposite: Take a JSON object and turn it into a COMPRESSED JWT Payload. The function that parses and decompresses: …outputs the JSON. …inputs the JSON. My attempt
Unit testing a method that creates a JWT and returns Error: secretOrPrivateKey must have a value
I am trying to write a unit test for the method I wrote which generates a JWT. I am doing the following Note: I am not using expect yet, and seeing if the method works in first place by logging the result of the method to the console And I receive the following error: Error: secretOrPrivateKey must have a value