workos-php-laravel
workos-php-laravel copied to clipboard
Call to undefined method WorkOS\\Resource\\Profile::json()
Seems like an old method.
My Code:
$sso = new \WorkOS\SSO();
$profile = $sso->getProfile($token);
Error:
"message": "Call to undefined method WorkOS\\Resource\\Profile::json()",
"exception": "Error",
"file": "/var/www/vendor/workos/workos-php/lib/SSO.php",
"line": 153,
Your code:
/**
* Verify that SSO has been completed successfully and retrieve the identity of the user.
*
* @param string $accessToken, the token used to authenticate the API call
*
* @throws Exception\GenericException
*
* @return \WorkOS\Resource\Profile
*/
public function getProfile($accessToken)
{
$getProfilePath = "sso/profile";
$params = [
"access_token" => $accessToken
];
$method = Client::METHOD_GET;
$url = "https://api.workos.com/sso/profile";
$requestHeaders = ["Authorization: Bearer " . $accessToken];
list($result) = Client::requestClient()->request(
$method,
$url,
$requestHeaders,
null
);
$decodedResponse = json_decode($result, true);
$profile = Resource\Profile::constructFromResponse($decodedResponse);
return $profile->json();
}
I'm on the latest version. If you cannot see why, please let me know.
Also, why do you have these that are not used anywhere.
$getProfilePath = "sso/profile";
$params = [
"access_token" => $accessToken
];
Are you using code generator? :)
Seems like an old method.
My Code:
$sso = new \WorkOS\SSO(); $profile = $sso->getProfile($token);Error:
"message": "Call to undefined method WorkOS\\Resource\\Profile::json()", "exception": "Error", "file": "/var/www/vendor/workos/workos-php/lib/SSO.php", "line": 153,Your code:
/** * Verify that SSO has been completed successfully and retrieve the identity of the user. * * @param string $accessToken, the token used to authenticate the API call * * @throws Exception\GenericException * * @return \WorkOS\Resource\Profile */ public function getProfile($accessToken) { $getProfilePath = "sso/profile"; $params = [ "access_token" => $accessToken ]; $method = Client::METHOD_GET; $url = "https://api.workos.com/sso/profile"; $requestHeaders = ["Authorization: Bearer " . $accessToken]; list($result) = Client::requestClient()->request( $method, $url, $requestHeaders, null ); $decodedResponse = json_decode($result, true); $profile = Resource\Profile::constructFromResponse($decodedResponse); return $profile->json(); }I'm on the latest version. If you cannot see why, please let me know.
Also, why do you have these that are not used anywhere.
$getProfilePath = "sso/profile"; $params = [ "access_token" => $accessToken ];Are you using code generator? :)