From fee3691b92799f0ac438a55c8959d299a8bdc159 Mon Sep 17 00:00:00 2001 From: Milos Trifunovic Date: Tue, 28 Nov 2023 20:18:54 +0100 Subject: [PATCH] auth dont return response --- languages/php/README.md | 2 +- languages/php/example.php | 2 +- languages/php/src/BitwardenClient.php | 3 +-- languages/php/src/BitwardenSettings.php | 35 +++++-------------------- 4 files changed, 9 insertions(+), 33 deletions(-) diff --git a/languages/php/README.md b/languages/php/README.md index 2bddf73ff..9e4a9385d 100644 --- a/languages/php/README.md +++ b/languages/php/README.md @@ -33,7 +33,7 @@ $identity_url = ""; $bitwarden_settings = new \Bitwarden\Sdk\BitwardenSettings($api_url, $identity_url); $bitwarden_client = new \Bitwarden\Sdk\BitwardenClient($bitwarden_settings); -$res = $bitwarden_client->access_token_login($access_token); +$bitwarden_client->access_token_login($access_token); ``` After successful authorization you can interact with client to manage your projects and secrets. diff --git a/languages/php/example.php b/languages/php/example.php index 687018f44..0fdb6930a 100644 --- a/languages/php/example.php +++ b/languages/php/example.php @@ -8,7 +8,7 @@ $client_settings = new \Bitwarden\Sdk\BitwardenSettings(); $bitwarden_client = new \Bitwarden\Sdk\BitwardenClient($client_settings); -$res = $bitwarden_client->access_token_login($access_token); +$bitwarden_client->access_token_login($access_token); // create project $res = $bitwarden_client->projects->create('php project', $organization_id); diff --git a/languages/php/src/BitwardenClient.php b/languages/php/src/BitwardenClient.php index bae1a0dff..79fccdf9c 100644 --- a/languages/php/src/BitwardenClient.php +++ b/languages/php/src/BitwardenClient.php @@ -28,6 +28,7 @@ public function __construct(BitwardenSettings $bitwardenSettings) $this->clientSettings = new ClientSettings(); $this->clientSettings->apiUrl = $bitwardenSettings->get_api_url(); $this->clientSettings->identityUrl = $bitwardenSettings->get_identity_url(); + $this->clientSettings->userAgent = "Bitwarden PHP-SDK"; $this->bitwarden_lib = new BitwardenLib(); $this->handle = $this->bitwarden_lib->init($this->clientSettings); @@ -54,8 +55,6 @@ public function access_token_login(string $access_token) if ($result->authenticated == False) { throw new \Exception("Unauthorized"); } - - return $result; } public function __destruct() diff --git a/languages/php/src/BitwardenSettings.php b/languages/php/src/BitwardenSettings.php index 34252866a..a0e5933ef 100644 --- a/languages/php/src/BitwardenSettings.php +++ b/languages/php/src/BitwardenSettings.php @@ -4,46 +4,23 @@ class BitwardenSettings { - private string $api_url; + private ?string $api_url; - private string $identity_url; - - private string $user_agent = "Bitwarden PHP SDK"; - -// private string $device_type; + private ?string $identity_url; public function __construct($api_url = null, $identity_url = null, $device_type = null) { - if (is_null($api_url)) - { - $this->api_url = 'https://api.bitwarden.com'; - } - - if (is_null($identity_url)) - { - $this->identity_url = 'https://identity.bitwarden.com'; - } - -// $this->device_type = $device_type ? isset($device_type) : ""; + $this->api_url = $api_url; + $this->identity_url = $identity_url; } - public function get_api_url(): string + public function get_api_url(): ?string { return $this->api_url; } - public function get_identity_url(): string + public function get_identity_url(): ?string { return $this->identity_url; } - - public function get_user_agent(): string - { - return $this->user_agent; - } - - public function get_device_type(): string - { - return $this->device_type; - } }