Skip to content

Commit da48774

Browse files
author
Phan Van Thanh
committed
Fix #3: Use createRequest() function instead of api() 🌻
1 parent b91d1a4 commit da48774

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

fproject/authclient/OAuth2.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,18 @@ public function getPublicKey()
154154

155155
if(empty($jwk))
156156
{
157-
$jwk = $this->api($this->jwkUrl, 'GET');
158-
if(!empty($jwk) && Yii::$app->cache)
159-
Yii::$app->cache->set($cacheKey, $jwk, self::PUBLIC_KEY_EXPIRE_DURATION);
157+
$res = $this->createRequest()
158+
->setMethod('GET')
159+
->setUrl($this->jwkUrl)
160+
->send();
161+
if(!empty($res)) {
162+
$jwk = $res->getContent();
163+
if(!empty($jwk) && Yii::$app->cache)
164+
Yii::$app->cache->set($cacheKey, $jwk, self::PUBLIC_KEY_EXPIRE_DURATION);
165+
} else {
166+
throw new UnauthorizedHttpException("Can\'t get public key");
167+
}
160168
}
161-
162169
if(!empty($jwk))
163170
$this->_publicKey = JWK::parseKeySet($jwk);
164171
}

0 commit comments

Comments
 (0)