Пример #1
0
 public function testClientSecretAddedIfSetForAuthorizationCodeRequests()
 {
     $testConfig = $this->tokenRequestMinimal;
     $testConfig['clientSecret'] = 'a_client_secret';
     $testConfig['redirectUri'] = 'https://has/redirect/uri';
     $o = new OAuth2($testConfig);
     $o->setCode('an_auth_code');
     $request = $o->generateCredentialsRequest();
     $fields = Psr7\parse_query((string) $request->getBody());
     $this->assertEquals('a_client_secret', $fields['client_secret']);
 }
 public function testGeneratesAuthorizationCodeRequests()
 {
     $testConfig = $this->tokenRequestMinimal;
     $testConfig['redirectUri'] = 'https://has/redirect/uri';
     $o = new OAuth2($testConfig);
     $o->setCode('an_auth_code');
     // Generate the request and confirm that it's correct.
     $req = $o->generateCredentialsRequest();
     $this->assertInstanceOf('GuzzleHttp\\Message\\RequestInterface', $req);
     $this->assertEquals('POST', $req->getMethod());
     $fields = $req->getBody()->getFields();
     $this->assertEquals('authorization_code', $fields['grant_type']);
     $this->assertEquals('an_auth_code', $fields['code']);
 }