PHPackages                             authress/authress-sdk.php - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. authress/authress-sdk.php

ActiveLibray[Authentication &amp; Authorization](/categories/authentication)

authress/authress-sdk.php
=========================

Client SDK for Authress authorization as a service. Provides managed authorization api to secure service resources including user data.

0.3.59(1y ago)4603[1 issues](https://github.com/Authress/authress-sdk.php/issues)Apache-2.0PHPPHP ~8.1.0 || ~8.2.0

Since Feb 16Pushed 1y ago3 watchersCompare

[ Source](https://github.com/Authress/authress-sdk.php)[ Packagist](https://packagist.org/packages/authress/authress-sdk.php)[ Docs](https://authress.io)[ RSS](/packages/authress-authress-sdkphp/feed)WikiDiscussions release/0.3 Synced 5d ago

READMEChangelogDependencies (6)Versions (33)Used By (0)

 [![Authress media banner](https://camo.githubusercontent.com/2fe13787785fa9ae3d2be0c8072b65994f37ae2440a206896f8718edfc9bdc76/68747470733a2f2f61757468726573732e696f2f7374617469632f696d616765732f6c696e6b6564696e2d62616e6e65722e706e67)](https://camo.githubusercontent.com/2fe13787785fa9ae3d2be0c8072b65994f37ae2440a206896f8718edfc9bdc76/68747470733a2f2f61757468726573732e696f2f7374617469632f696d616765732f6c696e6b6564696e2d62616e6e65722e706e67)

Authress SDK for PHP
====================

[](#authress-sdk-for-php)

Installation &amp; Usage
------------------------

[](#installation--usage)

Install authress-sdk for usage of the API:

`composer require authress/authress-sdk.php`

SDK usage
---------

[](#sdk-usage)

There's a full working example in this repository for how to flow can look like: [working example](./integrationTest/mock/index.php);

The full flow is usually:

- Check if user is logged in using `userSessionExists`
- If user is not logged in send them to your login page

    - On your login page ask the user which connection provider they want to use
    - Call `authenticate` with that `connectionId`
    - User will be redirected to the provider
- User will be returned to your redirectUrl

    - The redirectUrl page should include a code snippet from the [working example](./integrationTest/mock/index.php) and in the URL of your page will contain the `iss`, `code`, and `nonce` parameters (for validation, you don't need to worry how to handle them, but they need to be there this signals that the login worked correctly.)
- Call the `userSessionExists` method

    - This should work and return `true` at this moment

    You can also validate this worked by looking at the cookies for the app, which should contain `authorization` and `user` cookies. Please don't use these cookies directly as their format might change.

### Authorization

[](#authorization)

```
