I am encountering an error when testing my /api/token/refresh endpoint with the JWTRefreshTokenBundle library. The following error appears:
Unable to find the controller for path "/api/token/refresh". The route is wrongly configured.
I am using Symfony 7.0.7 and have followed the steps in the official documentation of JWTRefreshTokenBundle. My endpoint ‘api/login_check’ correctly returns the token and refresh_token, but when I call the URL /api/token/refresh, I get the error.
Here are my configurations for the JWT bundle:
“gesdinet/jwt-refresh-token-bundle”: “1.3.0”
“lexik/jwt-authentication-bundle”: “3.0.0”
I tried the solutions proposed on the JWTRefreshTokenBundle repo
security.yaml:
security:
password_hashers:
SymfonyComponentSecurityCoreUserPasswordAuthenticatedUserInterface: 'auto'
providers:
app_user_provider:
entity:
class: AppEntityUser
property: email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/api/login
stateless: true
json_login:
check_path: /api/login_check
username_path: email
password_path: password
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
refresh_jwt:
check_path: /api/token/refresh
api:
pattern: ^/api
stateless: true
jwt: ~
main:
lazy: true
provider: app_user_provider
access_control:
- { path: ^/api/(login|token/refresh), roles: PUBLIC_ACCESS }
- { path: ^/api/users/register, roles: PUBLIC_ACCESS }
- { path: ^/api/doc, roles: PUBLIC_ACCESS }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
config/routes.yaml:
controllers:
resource:
path: ../src/Controller/
namespace: AppController
type: attribute
api_login_check:
path: /api/login_check
api_refresh_token:
path: /api/token/refresh
config/routes.yaml:
controllers:
resource:
path: ../src/Controller/
namespace: AppController
type: attribute
api_login_check:
path: /api/login_check
api_refresh_token:
path: /api/token/refresh
config/routes/gesdinet_jwt_refresh_token.yaml:
gesdinet_jwt_refresh_token:
path: /api/token/refresh
config/packages/gesdinet_jwt_refresh_token.yaml:
gesdinet_jwt_refresh_token:
refresh_token_class: AppEntityRefreshToken
Axel Sanson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.