justinback/jbauth

There is no license information available for the latest version (1.0.1) of this package.

JBAuth is a OAuth 2.0 provider.

1.0.1 2018-12-15 11:14 UTC

This package is not auto-updated.

Last update: 2020-08-09 02:20:23 UTC


README

Installation

composer require justinback/jbauth:dev-master

Example

<?php
session_start();

include 'vendor/autoload.php';

$JBAuth = new \justinback\JBAuth("CLIENT_ID", "CLIENT_SECRET", "SCOPES AS SEPERATED LIST", "APIKEY");

if(!isset($_GET["code"])){

$CSRF = $JBAuth->authorize();
$_SESSION["RANDOM_CSRF_IDENTIFIER_TEST"] = $CSRF;
}

try {

if($_SESSION["RANDOM_CSRF_IDENTIFIER_TEST"] != $_GET["state"]){
    die("CSRF Mismatch!");
}

$Token = $JBAuth->token($_GET["code"]);
var_dump($Token);
echo "<br><br>";
$User = $JBAuth->user($Token->access_token);
var_dump($User);

} catch (Exception $ex){
    echo $ex;
}