Skip to content

Commit

Permalink
auth dont return response
Browse files Browse the repository at this point in the history
  • Loading branch information
milost77 committed Nov 28, 2023
1 parent 2b5ae7c commit fee3691
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 33 deletions.
2 changes: 1 addition & 1 deletion languages/php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $identity_url = "<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.
Expand Down
2 changes: 1 addition & 1 deletion languages/php/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions languages/php/src/BitwardenClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()
Expand Down
35 changes: 6 additions & 29 deletions languages/php/src/BitwardenSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit fee3691

Please sign in to comment.