Skip to content

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

@flexchar

Description

@flexchar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions