PHP code example of serato / sso-auth-request

1. Go to this page and download the library: Download serato/sso-auth-request library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

serato / sso-auth-request example snippets


use Serato\SsoRequest\AuthRequest;
use Serato\SsoRequest\AuthRequestDynamoDbStorage;

// Application ID of the web application
$appId = 'my-app-id';

// URI that the SSO service will redirect to after sign on
$redirectUri = 'http://my.server.com/uri/after/soo';

// Create a new AuthRequest
// Assumes `$awsSdk` is a correctly configured `Aws\Sdk` instance
$authRequest = AuthRequest::create(
    $appId,
    $redirectUri,
    new AuthRequestDynamoDbStorage($awsSdk)
);

// Get the new request ID
$requestId = $authRequest->getId();

 // Construct the SSO service URI to redirect the browser to
$ssoStartUri = 'http://sso.service.com?' . http_build_query([
    'app_id' => $appId,
    'state' => $authRequest->getId(),
    'redirect_uri' => $redirectUri
]);

## Redirect the browser to the SSO service

use Serato\SsoRequest\AuthRequest;
use Serato\SsoRequest\AuthRequestDynamoDbStorage;

// Application ID of the web application
$appId = 'my-app-id';

// Create a new AuthRequest
// Assumes `$awsSdk` is a correctly configured `Aws\Sdk` instance
// Assumes `$requestId` is obtained from the `state` URI parameter
$authRequest = AuthRequest::createFromStorage(
    $requestId,
    $appId,
    new AuthRequestDynamoDbStorage($awsSdk)
);

// Now fetch refresh and access tokens from the SSO service
// Assumes `$swsSdk` a configured `Serato\SwsSdk\Sdk` instance;
// Assumes `$code` is obtained from the `code` URI parameter
$result = $authRequest->getTokens($swsSdk, $code);

## $result is a `Serato\SwsSdk\Result` instance
## Use array access syntax to access result data