Adding User Authentication to a Simple PHP Application With Akamai Identity Cloud

July 7, 2020 · by Ajay Mishra ·

In this blog, we will add user authentication to a simple PHP web application with Akamai Identity Cloud. The primary use case is user registration and log in or out from a simple PHP application. In this example, we will use the OpenID Connect (OIDC) Authorization Code flow built into Akamai Identity Cloud as illustrated below.


You can complete the login life cycle for a simple PHP web app in just five steps.

Step 1. Gather Your Details

Gather your details from the Akamai Identity Cloud console, where the following are the arbitrary values:

Required Artifacts

Arbitrary Values


Authorization Endpoint 

UserInfo Endpoint

Customer ID


Client Secret




 Step 2. Configure PHP to Use Akamai Identity Cloud

Here you need to fill all of the values in a PHP configuration file (config_aic.php) as shown below. Simply create PHP constants to put all the values that we gathered in Step 1.


Step 3. Trigger Authentication

Let’s trigger the authorization endpoint to have a login link for the PHP application. This code will go to another file of index.php, which includes the config_aic.php file.

code blockcode block

A sign-in link is triggered:

sign in

Pressing the sign-in button will bring up Akamai’s pre-built hosted login page:

log in

At this point, you can register a Generic User (John Doe) as follows:

  • Complete the display name, email address, desired password, and confirm the password

log in

  • Now John Doe is registered and displayed


The login process is just as simple:

  • Insert user name and password

log in

  • John Doe is registered and displayed 


After registration or login, users are redirected to a “welcome.php” page where authentication transpires:

  • Exchanging access token with authorization code

code block

  • Using that access token to access user information from OIDC user info endpoint

code block

Step 4. Display User Information

Here, user information is fetched and displayed by calling the OIDC user info endpoint.


Step 5. Logout

As shown above, you can logout from the PHP application by pressing the "Logout" link. The link button is backed by the logout URL, resulting in the following pop-up:

login successful

For more coding examples of PHP with OIDC client and server visit:

You Might Also Like