fkooman\OAuth\Client\TokenRequest::withAuthorizationCode PHP Method

withAuthorizationCode() public method

public withAuthorizationCode ( $authorizationCode )
    public function withAuthorizationCode($authorizationCode)
    {
        $p = array('code' => $authorizationCode, 'grant_type' => 'authorization_code');
        if (null !== $this->clientConfig->getRedirectUri()) {
            $p['redirect_uri'] = $this->clientConfig->getRedirectUri();
        }
        return $this->accessTokenRequest($p);
    }

Usage Example

コード例 #1
0
 public function testWithAuthorizationCodeCredentialsInRequestBody()
 {
     $client = new Client();
     $mock = new MockPlugin();
     $mock->addResponse(new Response(200, null, $this->tokenResponse[0]));
     $client->addSubscriber($mock);
     $history = new HistoryPlugin();
     $history->setLimit(5);
     $client->addSubscriber($history);
     $tokenRequest = new TokenRequest($client, $this->clientConfig[1]);
     $tokenRequest->withAuthorizationCode("12345");
     $lastRequest = $history->getLastRequest();
     $this->assertEquals("POST", $lastRequest->getMethod());
     $this->assertEquals("code=12345&grant_type=authorization_code&redirect_uri=http%3A%2F%2Ffoo.example.org%2Fcallback&client_id=foo&client_secret=bar", $lastRequest->getPostFields()->__toString());
     $this->assertEquals("application/x-www-form-urlencoded; charset=utf-8", $lastRequest->getHeader("Content-Type"));
 }
All Usage Examples Of fkooman\OAuth\Client\TokenRequest::withAuthorizationCode