thephpleague/oauth2-server-bundle

Unable to read key from file

fd6130 opened this issue · 4 comments

PHP 8.1
Symfony 6.1

I got a strange error when trying to access /token api

Unable to read key from file /var/oauth/private.key

I have both public and private key in /var/oauth, and yet it keep prompt unable to read key error.

Yeah I have the same issue. Tried putting the key in root, still nothing

Can you try this :

  1. Put private.key and public.key in a config/jwt/ directory
  2. Reference them with the following instructions in league_oauth2_server.yaml file, under authorization_server and resource_server respectively.
private_key:          '%kernel.project_dir%/config/jwt/private.key'
public_key:           '%kernel.project_dir%/config/jwt/public.key'
  1. Check that the user running the web service, or php, has sufficient rights to read the private key, which is of course protected with a 600 mode.

@thejoelinux
Thank you man, it is working. I found a fix by putting the absolute path, but this is way better.

Sorry for not responding earlier, I totally missed this one. I'm going to have a look next week.