isg/thinkific-sso

This package is abandoned and no longer maintained. No replacement package was suggested.

A simple builder to help create single sign on (SSO) URIs for thinkific.

1.2.1 2017-09-07 14:00 UTC

This package is auto-updated.

Last update: 2020-07-20 17:09:15 UTC


README

https://isg.codebasehq.com/projects/other-associated-projects/repositories/thinkific-sso/tree/master

A simple builder to help create single sign on (SSO) URIs for thinkific.

This package is not official, or otherwise affiliated with, thinkific services.

Requirements

  • PHP 5.5+
  • ext_openssl

Usage

<?php
use Isg\ThinkificSSO\Builder;

$builder = new Builder(new \Lcobucci\JWT\Builder());

// Required fields.
$builder->setApiKey('1234567890'); // Your thinkific API key.
$builder->setSchool('myschool'); // e.g. myschool.thinkific.com
$builder->setId('12345678'); // A unique ID string for this request.
$builder->setEmail('fake@email.com'); // The user's email address.
$builder->setName('John', 'Smith'); // The user's first and last name.

// Optional fields.
$builder->setExternalId('my-external-id'); // An ID reference of the customer for your software.
$builder->setReturnUrl('https://mywebsite.com/training-return-url'); // Return URL on successful authentication.

// Optional fields, usable in the version 2 JWT endpoint only.
$builder->setBio('A pretty average guy.'); // A quick bio for the user.
$builder->setPhoneNumber('+441910000000'); // The user's contact number.
$builder->setCompany('John Smithson Ltd.'); // The company name the user works for.
$builder->setWebsite('https://john-smith.co.uk'); // The website associated with the user.
$builder->setTimezone('GMT'); // The timezone code of the user.
$builder->setErrorUrl('https://mywebsite.com/error-redirect-url'); // Error URL on authentication failure.

// Generate the single sign on URI.
$result = $builder->generateUri();

See http://help.thinkific.com/support/solutions/articles/221622-sso-v2-automatically-sign-in-from-your-own-website for more information about the parameters.

SSO Error Handling (v2 only)

You can use the Isg\ThinkificSSO\AuthResult class to check the error when the user is redirected to your error page:

<?php

$result = new \Isg\ThinkificSSO\AuthResult($_GET);

if ($result->hasError()) {
   echo $result->getMessage();
   error_log(sprintf('[%s] %s', $result->getOriginalErrorCode(), $result->getOriginalErrorMessage()));
}

// TODO

  • Tests for AuthResult
  • Better tests for Builder