Skip to content

Commit

Permalink
Merge pull request #2 from Wouter33/cachedauthorisation
Browse files Browse the repository at this point in the history
Since the original owner doesn't merge the PRs in, I am collecting all the patches and updates in this fork.

This update comes from @Wouter33 and allows passing the authentication key to constructor.
  • Loading branch information
tarikozket authored Dec 29, 2018
2 parents 0bdee40 + fe3b934 commit ec85d05
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Client
*/
public function __construct($accountId, $applicationKey, array $options = [])
{

$this->accountId = $accountId;
$this->applicationKey = $applicationKey;

Expand All @@ -34,8 +35,15 @@ public function __construct($accountId, $applicationKey, array $options = [])
} else {
$this->client = new HttpClient(['exceptions' => false]);
}

if(!empty($options['authorization'])){
$this->authToken = $options['authorization']['authToken'];
$this->apiUrl = $options['authorization']['apiUrl'];
$this->downloadUrl = $options['authorization']['downloadUrl'];
} else {
$this->authorizeAccount();
}

$this->authorizeAccount();
}

/**
Expand Down Expand Up @@ -399,6 +407,22 @@ public function deleteFile(array $options)

return true;
}

/**
* Retrieve authorization details from connection
*
* @return array
*/
public function getAuthorization()
{

return [
'authToken' => $this->authToken,
'apiUrl' => $this->apiUrl,
'downloadUrl' => $this->downloadUrl
];

}

/**
* Authorize the B2 account in order to get an auth token and API/download URLs.
Expand Down

0 comments on commit ec85d05

Please sign in to comment.