Skip to content
Peter Adams edited this page Nov 7, 2021 · 13 revisions

Installation

Credentials

Use of the SDK requires OWA Server credentials:

  1. API Key - this is the public key generated for each OWA user. It can be found on the user's admin profile page.
  2. Secret Auth Key - this the secret OWA_AUTH_KEY for your OWA Server instance. It's found in the owa-config.php file of your OWA Server instance.

These credentials can be made available to the to clients in one of the following ways:

  • Passed to client factory as part of configuration array
  • As environment variables
  • As PHP constants
  • A local file

Passing Credentials to Clients via their factories

You can pass credentials to any of the SDK's clients at the time of their creation.

$config = [
	
	'instance_url' => 'http://test.openwebanalytics.com/owa/'
        'credentials'  => [
            'api_key'      => 'YOUR_OWA_API_KEY'
            'auth_key'      => 'YOUR_SECRET_OWA_AUTH_KEY'
        ]
];
$sdk = new OwaSdk\sdk( $config );
$sites = $sdk->createSites();

Storing Credentials in Environmental Variables

If you do not provide credentials to a client object at the time of its instantiation, the SDK will attempt to find credentials in your environment when you call your first operation. The SDK will use the $_SERVER superglobal and/or getenv() function to look for the OWA_API_KEY and OWA_AUTH_KEY environment variables.

Storing Credentials in PHP Constants

Credentials can be defined as PHP constants as part of your application like so:

define('OWA_API_KEY', 'your-api-key-goes-here');
define('OWA_AUTH_KEY', 'your-secret-key-goes-here');

Storing Credentials in a local credentials file

You can use a local credentials file to specify your credentials. This is a special, INI-formatted file stored under your HOME directory. The file should be placed at ~/.owa/credentials, where ~ represents your HOME directory.

The credentials should be stored in INI format like so:

[default]
api_key = YOUR_OWA_API_KEY
auth_key = YOUR_OWA_SECRET_AUTH_KEY

Clients

Clone this wiki locally