validationjwttwilioaccess-tokenrefresh-token

Twilio Access Token - how can I check that JWT token (created with Twilio) is expired, from Swift side?


I want to be able to check that a Twilio Access Token is expired. I have the Twilio account and I can generate the Access Token as JWT. I can manually clearly see the expiry time in jwt.io website, but I need to do this in Laravel Twilio or in Swift client. How can I see if that token is expired, that from Swift side? How could I do that from Twilio Laravel's side?


Solution

  • It turned out it was simple, but had to find a way to put it. So, it is:

    $decodedJwt = JWT::decode($token, $this->apiSecret);
    
    $tokenExpiryTime = $decodedJwt->exp;
    
    if (time() > $tokenExpiryTime) {
        $is = true;
    } else {
        $is = false;
    }