PHPackages                             akamai-open/edgegrid-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. akamai-open/edgegrid-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

akamai-open/edgegrid-client
===========================

Implements the Akamai {OPEN} EdgeGrid Authentication specified by https://developer.akamai.com/introduction/Client\_Auth.html

2.1.2(2mo ago)482.5M—7.4%566Apache-2.0PHPPHP &gt;=8.2CI passing

Since Jul 14Pushed 2mo ago26 watchersCompare

[ Source](https://github.com/akamai/AkamaiOPEN-edgegrid-php-client)[ Packagist](https://packagist.org/packages/akamai-open/edgegrid-client)[ Docs](https://github.com/akamai-open/AkamaiOPEN-edgegrid-php)[ RSS](/packages/akamai-open-edgegrid-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (22)Versions (28)Used By (6)

akamai-open/edgegrid-client
===========================

[](#akamai-openedgegrid-client)

[Akamai EdgeGrid Authentication](https://techdocs.akamai.com/developer/docs/set-up-authentication-credentials) for PHP.

This library requires PHP 8+ and implements the Akamai EdgeGrid Authentication scheme on top of [Guzzle](https://github.com/guzzle/guzzle) as both a drop-in replacement client and middleware.

Installation
------------

[](#installation)

To install, use [`composer`](http://getcomposer.org):

```
$ composer require akamai-open/edgegrid-client
```

### Alternative installation method

[](#alternative-installation-method)

Download the PHAR file from the [releases](https://github.com/akamai/AkamaiOPEN-edgegrid-php/releases) page and include it inside your code:

```
include 'akamai-open-edgegrid-auth.phar';

// Library is ready to use
```

Authentication
--------------

[](#authentication)

You can obtain the authentication credentials through an API client. Requests to the API are marked with a timestamp and a signature and are executed immediately.

1. [Create authentication credentials](https://techdocs.akamai.com/developer/docs/edgegrid).
2. Place your credentials in an EdgeGrid file `~/.edgerc`, in the `[default]` section.

    ```
    [default]
    client_secret = C113nt53KR3TN6N90yVuAgICxIRwsObLi0E67/N8eRN=
    host = akab-h05tnam3wl42son7nktnlnnx-kbob3i3v.luna.akamaiapis.net
    access_token = akab-acc35t0k3nodujqunph3w7hzp7-gtm6ij
    client_token = akab-c113ntt0k3n4qtari252bfxxbsl-yvsdj

    ```
3. Use your local `.edgerc` by providing credentials' section header and the path to your resource file. You can call your `.edgerc` file using the `\Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile()` method.

    The location of your `.edgerc` file is optional, as it defaults to `~/.edgerc`.

    ```
    $client = \Akamai\Open\EdgeGrid\Client::createFromEdgeRcFile('{credentials_section_name}', '{path/to/.edgerc}');

    // Use $client just as you would \Guzzle\Http\Client
    $response = $client->get('/identity-management/v3/user-profile');
    ```

    Alternatively, you can hard code your credentials by passing the credential values to the `\Akamai\Open\EdgeGrid\Client->setAuth()` method.

    ```
    $client = new Akamai\Open\EdgeGrid\Client([
    'base_uri' => 'https://akab-h05tnam3wl42son7nktnlnnx-kbob3i3v.luna.akamaiapis.net'
    ]);

    $client_token = 'akab-c113ntt0k3n4qtari252bfxxbsl-yvsdj';
    $client_secret = 'C113nt53KR3TN6N90yVuAgICxIRwsObLi0E67/N8eRN=';
    $access_token = 'akab-acc35t0k3nodujqunph3w7hzp7-gtm6ij';

    $client->setAuth($client_token, $client_secret, $access_token);

    // use $client just as you would \Guzzle\Http\Client
    $response = $client->get('/identity-management/v3/user-profile');
    ```

Use
---

[](#use)

The `Akamai\Open\EdgeGrid\Client` extends `\GuzzleHttp\Client` as a drop-in replacement. It works transparently to sign API requests without changing other ways you use Guzzle.

Include the autoloader to import all the required classes.

Provide your credentials section header and appropriate endpoint information.

```
