Auth0\SDK\API\Authentication::tokeninfo PHP Method

tokeninfo() public method

public tokeninfo ( $id_token )
    public function tokeninfo($id_token)
    {
        return $this->apiClient->get()->tokeninfo()->withHeader(new ContentType('application/json'))->withBody(json_encode(['id_token' => $id_token]))->call();
    }

Usage Example

Exemplo n.º 1
0
 public function testAuthorizeWithRO()
 {
     $env = $this->getEnv();
     $api = new Authentication($env['DOMAIN'], $env['APP_CLIENT_ID']);
     $response = $api->authorize_with_ro('*****@*****.**', '123456', 'openid', 'Username-Password-Authentication');
     $this->assertArrayHasKey('id_token', $response);
     $this->assertArrayHasKey('access_token', $response);
     $this->assertArrayHasKey('token_type', $response);
     $this->assertEquals('bearer', $response['token_type']);
     $userinfo = $api->userinfo($response['access_token']);
     $this->assertArrayHasKey('email', $userinfo);
     $this->assertArrayHasKey('email_verified', $userinfo);
     $this->assertArrayHasKey('user_id', $userinfo);
     $this->assertEquals('*****@*****.**', $userinfo['email']);
     $this->assertEquals('auth0|57e293c6247600bf0ba47fc2', $userinfo['user_id']);
     $tokeninfo = $api->tokeninfo($response['id_token']);
     $this->assertArrayHasKey('email', $tokeninfo);
     $this->assertArrayHasKey('email_verified', $tokeninfo);
     $this->assertArrayHasKey('user_id', $tokeninfo);
     $this->assertEquals('*****@*****.**', $tokeninfo['email']);
     $this->assertEquals('auth0|57e293c6247600bf0ba47fc2', $tokeninfo['user_id']);
 }