markitosgv / JWTRefreshTokenBundle

Implements a Refresh Token system over Json Web Tokens in Symfony
MIT License
664 stars 160 forks source link

JWT Token not found #129

Open cristhianDt opened 5 years ago

cristhianDt commented 5 years ago

Hi,

When I call /api/token/refresh, the response is 401.

The request: curl -X POST \ http://127.0.0.1:8000/api/token/refresh \ -H 'Content-Type: application/x-www-form-urlencoded' \ -H 'Postman-Token: 484cd44f-3646-4052-b9d4-2a9ce1c4fb0b' \ -H 'cache-control: no-cache' \ -d 'refresh_token=xxxRefreshTokenxxx'

composer.json: "require": { "php": ">=7.2.0", "ext-json": "*", "doctrine/doctrine-bundle": "^1.6", "doctrine/doctrine-fixtures-bundle": "^3.0", "doctrine/doctrine-migrations-bundle": "^1.3", "doctrine/orm": "^2.5", "friendsofsymfony/rest-bundle": "^2.4", "fzaninotto/faker": "^1.8", "gesdinet/jwt-refresh-token-bundle": "^0.5.4", "incenteev/composer-parameter-handler": "^2.0", "kriswallsmith/buzz": "0.17.1", "lexik/jwt-authentication-bundle": "^2.6", "nelmio/cors-bundle": "^1.5", "sensio/distribution-bundle": "^5.0.19", "sensio/framework-extra-bundle": "^5.0.0", "sonata-project/admin-bundle": "^3.42", "sonata-project/doctrine-orm-admin-bundle": "^3.6", "symfony/monolog-bundle": "^3.1.0", "symfony/polyfill-apcu": "^1.0", "symfony/requirements-checker": "^1.1", "symfony/swiftmailer-bundle": "^2.6.4", "symfony/symfony": "3.4.*", "twig/twig": "^1.0||^2.0" }

could you help me?,

norkunas commented 5 years ago

@cristhianDt did you resolve your issue?

erik-seifert commented 5 years ago

Same too me. How do you resolve this issue ?

mpmaghribi commented 5 years ago

In my case, it happens because wrong pattern on security.yaml

i wrote: pattern: ^token/refresh

should be: pattern: ^/token/refresh

sashok1337 commented 5 years ago

Hello everyone!

In my case everything fixes after putting token-refresh firewall rule before api rule.

    token-refresh:
        pattern:  ^/api/token/refresh
        stateless: true
        anonymous: true

    api:
        pattern:   ^/api
        stateless: true
        guard:
            authenticators:
                - lexik_jwt_authentication.jwt_token_authenticator