PHP code example of own3d / id

1. Go to this page and download the library: Download own3d/id 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/ */

    

own3d / id example snippets


use SocialiteProviders\Manager\SocialiteWasCalled;
use Own3d\Id\Socialite\Own3dIdExtendSocialite;

/**
 * The event handler mappings for the application.
 *
 * @var array
 */
protected $listen = [
    SocialiteWasCalled::class => [
        // add your listeners (aka providers) here
        Own3dIdExtendSocialite::class,
    ],
];

'own3d-id' => [
    'client_id' => env('OWN3D_ID_KEY'),
    'client_secret' => env('OWN3D_ID_SECRET'),
    'redirect' => env('OWN3D_ID_REDIRECT_URI')
],

$own3dId = new Own3d\Id\Own3dId();

$own3dId->setClientId('abc123');

...

$own3dId = new Own3d\Id\Own3dId();

$own3dId->setClientId('abc123');
$own3dId->setClientSecret('abc456');
$own3dId->setToken('abcdef123456');

$own3dId = $own3dId->withClientId('abc123');
$own3dId = $own3dId->withClientSecret('abc123');
$own3dId = $own3dId->withToken('abcdef123456');

$own3dId = new Own3d\Id\Own3dId();

$own3dId->setClientId('abc123');
$own3dId->setToken('abcdef123456');

$result = $own3dId->getAuthedUser();

$user = $userResult->shift();

$own3dId->setToken('uvwxyz456789');

$result = $own3dId->getAuthedUser();

$result = $own3dId->withToken('uvwxyz456789')->getAuthedUser();

use Own3d\Id\Facades\Own3dId;

Own3dId::withClientId('abc123')->withToken('abcdef123456')->getAuthedUser();

public function retrievingToken(string $grantType, array $attributes)

public function getAuthedUser()
public function setAuthedUserEmailAddress(string $email)
public function getUserById(string $id)
public function getUsersByEmail(string $email)
public function getUserConnections(array $parameters = [])
public function getUserConnectionByPlatformId(string $platform, string $id)

public function sendEvent(string $type, array $data, string $version)

Route::get('/user', function () {
    //
})->middleware('auth:api');

'api' => [
    'driver' => 'own3d-id',
    'provider' => 'users',
],

'api-customers' => [
    'driver' => 'own3d-id',
    'provider' => 'customers',
],

Route::get('/customer', function () {
    //
})->middleware('auth:api-customers');

Route::get('/redirect', function () {
    $query = http_build_query([
        'client_id' => 'client-id',
        'redirect_uri' => 'http://example.com/callback',
        'response_type' => 'code',
        'scope' => 'user:read connections',
    ]);

    return redirect('https://id.stream.tv/oauth/authorize?' . $query);
});

TBD

'scopes' => \Own3d\Id\Http\Middleware\CheckScopes::class,
'scope' => \Own3d\Id\Http\Middleware\CheckForAnyScope::class,

Route::get('/test', function () {
    // Access token has both "user:read" and "connections" scopes...
})->middleware(['auth:api', 'user:read,connections']);

Route::get('/test', function () {
    // Access token has either "user:read" or "connections" scope...
})->middleware(['auth:api', 'scope:user:read,connections'])

use Illuminate\Http\Request;

Route::get('/orders', function (Request $request) {
    if ($request->user()->tokenCan('user:read')) {
        //
    }
});

use Own3d\Id\Http\Middleware\CheckClientCredentials;

protected $routeMiddleware = [
    'client' => CheckClientCredentials::class,
];

Route::get('/test', function (Request $request) {
    ...
})->middleware('client');

Route::get('/test', function (Request $request) {
    ...
})->middleware('client:user:read,your-scope');

'guards' => [
    ...

    'api' => [
        'driver' => 'own3d-id',
        'provider' => 'sso-users',
    ],
],

'providers' => [
    ...

    'sso-users' => [
        'driver' => 'sso-users',
        'model' => App\Models\User::class,
        'fields' => ['name', 'email', 'email_verified_at'],
    ],
],

use Illuminate\Http\Request;
use Own3d\Id\Auth\Own3dSsoUserProvider;
use Own3d\Id\Own3dId;

public function boot()
{
    ...

    Own3dIdGuard::register();
    Own3dSsoUserProvider::register();
}

$ php artisan vendor:publish --provider="Own3d\Id\Providers\Own3dIdServiceProvider"