-
-
Notifications
You must be signed in to change notification settings - Fork 13
Home
Use of the SDK requires OWA Server credentials:
- API Key - this is the public key generated for each OWA user. It can be found on the user's admin profile page.
- Secret Auth Key - this the secret
OWA_AUTH_KEY
for your OWA Server instance. It's found in theowa-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
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();
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.
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');
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