Skip to content

Commit

Permalink
- fix authorize grant type
Browse files Browse the repository at this point in the history
- user authorize code parameter is not required now
  • Loading branch information
vt-parhomenko committed Jan 13, 2021
1 parent 2e44d5f commit 24e57b6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Api/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,18 @@ public function getOAuthLink( string $redirect_uri = null, string $state = null
* @return User
* @throws \Exception
*/
public function authorize( string $code, $redirect_uri = null ) : self
public function authorize( string $code = null, $redirect_uri = null ) : self
{
try{

$request_data = [
'client_id' => $this->client_id,
'client_secret' => $this->client_secret,
'grant_type' => self::OLX_AUTH_DEFAULT_GRAND_TYPE,
'scope' => $this->scope,
'code' => $code
'grant_type' => $this->grant_type,
'scope' => $this->scope
];

if( !is_null($code) ) $request_data['code'] = $code;
if( !is_null($redirect_uri) ) $request_data['redirect_uri'] = $redirect_uri;

$response = $this->guzzleClient->request('POST', self::OLX_AUTH_REQUEST_URI, [ 'json' => $request_data ] );
Expand All @@ -178,7 +178,7 @@ public function authorize( string $code, $redirect_uri = null ) : self
if( !empty($data['access_token']) ){
$this->access_token = $data['access_token'];
$this->token_type = $data['token_type'];
$this->refresh_token = $data['refresh_token'];
if( !empty($data['refresh_token']) ) $this->refresh_token = $data['refresh_token'];
$this->token_expires_in = $data['expires_in'];
$this->token_updated_at = date( "Y-m-d H:i:s");
}else{
Expand Down

0 comments on commit 24e57b6

Please sign in to comment.