Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to undefined method WorkOS\\Resource\\Profile::json() #56

Open
flexchar opened this issue Feb 27, 2025 · 0 comments
Open

Call to undefined method WorkOS\\Resource\\Profile::json() #56

flexchar opened this issue Feb 27, 2025 · 0 comments

Comments

@flexchar
Copy link

flexchar commented Feb 27, 2025

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? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant