【问题标题】:Undefined index: client_id while using Laravel 5.1 / Socialite / Dropbox SDK未定义索引:使用 Laravel 5.1 / Socialite / Dropbox SDK 时的 client_id
【发布时间】:2015-09-09 01:29:50
【问题描述】:

所以我意识到 Laravel 5.1 在通过 OAuth2 对用户进行身份验证时无法使用会话来存储 Dropbox SDK 所需的 CSRF 令牌。为了解决这个问题,我按照this great post 使用this providerLaravel Socialite 为我进行OAuth2 调用,但是,即使在按照该文档进行操作之后,我仍然收到以下错误:

ErrorException in SocialiteManager.php line 91: Undefined index: client_id

我找不到client_id 甚至会成为流中的索引的位置,所以我对此感到非常困惑。任何帮助将不胜感激。

以下是激发社交名流/Dropbox 服务提供商的方法:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

// other Classes
use App\User;
use Hash;
use Input;
use Auth;
use DB;
use Socialize;

class UserController extends Controller
{
    public function showDropbox()
    {
        return Socialize::driver('dropbox')->redirect();
    }
}

【问题讨论】:

    标签: php laravel-5.1 dropbox-php laravel-socialite


    【解决方案1】:

    这是一件非常简单的事情,完全是我的疏忽……我在教程所需的 config/services.php 文件中有错误的索引。

    我有……

    'dropbox' => [
        'redirect'  => env('DROPBOX_REDIRECT_URI'),
        'key'    => env('DROPBOX_KEY'),
        'secret' => env('DROPBOX_SECRET'),
    ],
    

    ...当我应该拥有的时候:

    'dropbox' => [
        'redirect'  => env('DROPBOX_REDIRECT_URI'),
        'client_id'    => env('DROPBOX_KEY'),
        'client_secret' => env('DROPBOX_SECRET'),
    ],
    

    希望对某人有所帮助!

    【讨论】:

    • 感谢帮助我。我实际上是在使用 $_ENV['CREDENTIAL_NAME'] 并且显然 5.1 更喜欢 env('CREDENTIAL_NAME')
    猜你喜欢
    • 2016-04-15
    • 2015-12-30
    • 1970-01-01
    • 2018-08-02
    • 2012-08-24
    • 2015-03-23
    • 1970-01-01
    • 1970-01-01
    • 2015-09-27
    相关资源
    最近更新 更多