odan / slim4-skeleton

A Slim 4 Skeleton
https://odan.github.io/slim4-skeleton/
MIT License
446 stars 80 forks source link

Authorization 401 #15

Closed bukohub closed 4 years ago

bukohub commented 4 years ago

Hi friend, thank you for this framework.

I got a issue con the authorization (JWT), always stay in status 401, but I don't know for what. The API generate TOKEN, but is false in this line:

` public function validateToken(string $accessToken): bool { $token = $this->createParsedToken($accessToken);

    //This is my error false----------------------------------------------------------
    if (!$token->verify($this->signer, $this->publicKey)) {
        // Token signature is not valid
        return false;
    }

    // Check whether the token has not expired
    $data = new ValidationData();
    $data->setCurrentTime(Chronos::now()->getTimestamp());
    $data->setIssuer($token->getClaim('iss'));
    $data->setId($token->getClaim('jti'));

    return $token->validate($data);
}`

What is your recommend? Thank u friend.

odan commented 4 years ago

Hi! Check that your private and public key is valid. In your other comment I saw < br /> in your private key, which is not valid. Try to recreate the private and the public key.

bukohub commented 4 years ago

Hi @odan, thank u for u answer. When I copy the keys and paste in the settings the editor generate space and this is the issue. Just remove space in the editor.

Thank u friend