molbal/eveonline-socialite

EveOnline SSO 提供商用于 Laravel Socialite

1.0.1 2021-01-14 18:59 UTC

This package is auto-updated.

Last update: 2024-09-15 03:55:13 UTC


README

我并不声称是该包的作者,我仅仅更新了依赖项

安装和配置

安装 Laravel Socialite(见此处: https://github.com/laravel/socialite/blob/2.0/readme.md

安装 eveonline socialite 提供商

composer require molbal/eveonline-socialite

将以下内容添加到您的 .env 文件中

EVEONLINE_CLIENT_ID=
EVEONLINE_CLIENT_SECRET=
EVEONLINE_REDIRECT=

(获取您的 Eve Online SSO 凭据: https://developers.eveonline.com/applications/

Laravel <= 5.4

将以下内容添加到您的 config/app.php 中

Sayorus\Socialite\EveOnline\Providers\EveOnlineServiceProvider::class,

Laravel 5.5

服务提供者将自动发现。

使用方法

<?php

namespace App\Http\Controllers\Auth;

use Socialite;

class AuthController extends Controller
{
    /**
     * Redirect the user to the Eve Online authentication page.
     *
     * @return Response
     */
    public function redirectToProvider()
    {
        return Socialite::driver('eveonline')->redirect();
    }

    /**
     * Obtain the user information from Eve Online.
     *
     * @return Response
     */
    public function handleProviderCallback()
    {
        $user = Socialite::driver('eveonline')->user();

        //dd($user);
    }
}

检索用户详情

一旦您有了用户实例,您就可以获取更多关于该用户的信息

$user = Socialite::driver('eveonline')->user();

$token = $user->token;
$expiresIn = $user->expiresIn;
$user->getId();
$user->getName();
$user->getAvatar();