【问题标题】:Guide me implementing OAuth2 storage classes in thephpleague library指导我在 phpleague 库中实现 OAuth2 存储类
【发布时间】:2015-04-01 02:04:27
【问题描述】:

我正在使用 Alex Bilbie 提供的 phpleague 库开发一个 oAuth 2.0 服务器。但是,在初始化授权服务器之后,当我声明存储类时,它会引发以下错误。

“致命错误:找不到类 'Storage\SessionStorage'”

请帮我解决这个问题。我在这里阅读了您关于此问题的帖子:- Guide me implementing Oauth2 PHP server using thephpleague library

请告诉我如何实现存储类。我当前的代码:

require_once "/../vendor/autoload.php";
$server = new \League\OAuth2\Server\AuthorizationServer;
$server->setSessionStorage(new Storage\SessionStorage);
$server->setAccessTokenStorage(new Storage\AccessTokenStorage);
$server->setClientStorage(new Storage\ClientStorage);
$server->setScopeStorage(new Storage\ScopeStorage);
$server->setAuthCodeStorage(new Storage\AuthCodeStorage);
$authCodeGrant = new \League\OAuth2\Server\Grant\AuthCodeGrant();
$server->addGrantType($authCodeGrant); 

【问题讨论】:

  • 你的代码是什么样的?
  • 我使用 composer 安装了库,这里是命令:-“composer 需要联盟/oauth2-server”。这里是路径结构:- D:\wamp\www\demos\oAuth\oAuth2\vendor\league\oauth2-server\src\ "ALL LIBRARY CLASSES" 和 Auload.php 文件路径是:- D:\wamp\www \demos\oAuth\oAuth2\vendor\autoload.php

标签: php oauth-2.0 thephpleague


【解决方案1】:

您使用的库需要实现您自己的存储类,请参阅http://oauth2.thephpleague.com/implementing-storage-interfaces/。您使用的类名来自使用 Capsule 作为其存储后端的示例实现 https://github.com/thephpleague/oauth2-server/tree/master/examples/relational/Storage。如果您想使用 Capsule 作为后端,则需要下载这些示例实现类并安装 https://github.com/illuminate/database

【讨论】:

  • 对不起,汉兹,但我没有得到你的答案。我将存储文件夹从github.com/thephpleague/oauth2-server/tree/master/examples/… 放到我的本地目录,但它仍然抛出错误。而且,我尝试运行关系示例。但是,不幸的是它也会抛出这个错误。
  • 他们需要在Storage目录中
  • 是的,这是我的存储目录路径:- D:\wamp\www\demos\oAuth\oAuth2\Storage\ ALL STORAGE CLASS
猜你喜欢
  • 2014-12-06
  • 1970-01-01
  • 2013-11-21
  • 2017-11-03
  • 2019-03-14
  • 2018-03-01
  • 2015-08-19
  • 2012-03-30
  • 2014-05-05
相关资源
最近更新 更多