I had a problem, when I deploy my project into Heroku I try to register but this error comes out I try all solving I search for but doesn’t help me, I use php artisan:migrate
, php artisan passport:keys
and php artisan passport:install --force
, but no one help 🙁
{message: "Invalid key supplied", exception: "LogicException",…}
exception: "LogicException"
file: "/app/vendor/league/oauth2-server/src/CryptKey.php"
line: 67
message: "Invalid key supplied"
public function __construct($keyPath, $passPhrase = null, $keyPermissionsCheck = true)
{
$this->passPhrase = $passPhrase;
if (strpos($keyPath, self::FILE_PREFIX) !== 0 && $this->isValidKey($keyPath, $this->passPhrase ?? '')) {
$this->keyContents = $keyPath;
$this->keyPath = '';
// There's no file, so no need for permission check.
$keyPermissionsCheck = false;
} elseif (is_file($keyPath)) {
if (strpos($keyPath, self::FILE_PREFIX) !== 0) {
$keyPath = self::FILE_PREFIX . $keyPath;
}
if (!is_readable($keyPath)) {
throw new LogicException(sprintf('Key path "%s" does not exist or is not readable', $keyPath));
}
$this->keyContents = file_get_contents($keyPath);
$this->keyPath = $keyPath;
if (!$this->isValidKey($this->keyContents, $this->passPhrase ?? '')) {
throw new LogicException('Unable to read key from file ' . $keyPath);
}
} else { // ***** line 67 *****
throw new LogicException('Invalid key supplied');
}
if ($keyPermissionsCheck === true) {
// Verify the permissions of the key
$keyPathPerms = decoct(fileperms($this->keyPath) & 0777);
if (in_array($keyPathPerms, ['400', '440', '600', '640', '660'], true) === false) {
trigger_error(
sprintf(
'Key file "%s" permissions are not correct, recommend changing to 600 or 660 instead of %s',
$this->keyPath,
$keyPathPerms
),
E_USER_NOTICE
);
}
}
}
I want to find what’s is the problem because I try to solve it for a week
finally I find the solution add this in .env
PASSPORT_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
<private key here>
-----END RSA PRIVATE KEY-----"
PASSPORT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----
<public key here>
-----END PUBLIC KEY-----"
just write your key to be like this
PASSPORT_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
MIIJQQIBADANBgkqhkiG9w0BAQEF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NP/MpVgAC43nWzYocM0E2lBWilYrmhuy7
IO9pqmID9iX0XP1TeHCKeW+FQrpzteeLBTjMU3GpRBeDCnOCdkgyWz2gukgGrH/h
4tAMlzeYgHtgDT8ZJWR3i7swwnp8o5PJOblELMzpKEQTJIPVflfYN2q+bE/W7iqI
M/A7U88RA4JylrFUKiJYnmAM2F2NyvVe31SPwFSxL0Exk5EIK6Suwz/5SV543pm9
X1R7EK5qOJxadd3X5X+W30BJ1KZMi+Nd7LdpU4vDm7YpBL7Ce0Wip1ctO87440MB
xGjoWo8f3PDAQ9A2mtf78Ez1Jy2X5V6HCYY7O/kCggEAIA0MPaB80d3xv9+3HcDO
xYUkZ7sCNBxckj09CRYdqkg5i+3uQ+AhFrULjwW5nBu0b5YAn+JqMAZAJP5kLvSy
c0ZTJL4Ktt0hviyz8RYhudIViaPVCUL7L4vd6O9O8GM95PUgd0FQ0c0a76fJ2csa
MwIR0gq5fxpZbfSK1nsPl1d9WmoniPCOoqjbdr2idbTghgIiH2O4lyVrtiLA7Lvz
2aLadGazFlnZCRLHCuxCPnJ0AOQau1yVBr/f+uxQC/ZbCp+WjkBx/cl8A78DWSMw
W0+jVZ4IexYUiy9oKwfg4h2fqBHaiszWXBLPK4bXOpEnxItq3irn5UWvRg1eLpyq
7wKCAQAVEO01v9u3inhiKpXJRzcJrN1pnLVItcZLbeWoySOE0dWzqrWk16YJiD/G
VpwE6FRUU/4a/Y6KXZqdiCnFcKRS7Q1tAurQ+IfGAyYGPmuir2p/H9gQDGEBLgW1
gzqxxZ5i9xE1Y+kXK2FmY96i2VfT+wnkBVENJAEMKrh3961Mqz7ZmC9B2hXpvMor
loTh10jWTsIvNjt7LHUNA/neRxRj4KfO6EqHgYO41P6U93ZJ
-----END RSA PRIVATE KEY-----"
2
Answers
I finally find the solution add this in
.env
just write your key to be like this
Try run