joomla/oauth1
Composer 安装命令:
composer require joomla/oauth1
包简介
Joomla OAuth1 Package
关键字:
README 文档
README
Using the OAuth1 Package
The OAuth1 package supports OAuth 1.0 and 1.0a protocol versions. The client facilitates authorised RESTful HTTP requests. You can find the OAuth RFC at http://tools.ietf.org/html/rfc5849.
The Client is abstract, it must be extended and have the two abstract methods implemented. These methods are verifyCredentials and validateResponse:
- verifyCredentials is used to check if an existing access token is still valid. Servers may have different ways of testing the access token validity, for example Twitter has a specific URL for this. There are several reasons an access token may be invalid: the token expires after some time, the user changes his password which invalidates the access token, the user de-authorizes your app, the user logs out.
- validateResponse method is used to check the response codes. This method abstract because servers may have different response error bodies.
By default the client will act as an OAuth 1.0a client. If you need an OAuth 1.0 client, than you have to set the constructor $version parameter to '1.0'. The client requires additional options and this can be done by injecting in a Registry object:
use Joomla\Oauth1\Client; use Joomla\Registry\Registry; $options = new Registry; $options->set('consumer_key', $key); $options->set('consumer_secret', $secret); $options->set('callback', $my_url); $options->set('accessTokenURL', $accessToken); $options->set('authenticateURL', $authenticate); $options->set('authoriseURL', $authorise); $options->set('requestTokenURL', $requestToken); // Call the Client constructor. parent::__construct($this->options);
By default you have to set and send headers manually in your application, but if you want this to be done automatically by the client you can set Registry option 'sendheaders' to true.
$options->set('sendheaders', true);
Now you can authenticate the user and request him to authorise your application in order to get an access token, but if you already have an access token stored you can set it and if it's still valid your application will use it.
// Set the stored access token. $oauth->setToken($token); $access_token = $oauth->authenticate();
When calling the authenticate() method, your stored access token will be used only if it's valid, a new one will be created if you don't have an access token or if the stored one is not valid. The method will return a valid access token that's going to be used.
Now you can perform authorised requests using the oauthRequest method.
A More Complete Example
See the Twitter and LinkedIn packages for examples demonstrating more about the OAuth1 package.
TODO: add links to the Twitter and LinkedIn packages after this packages are merged.
More Information
The following resources contain more information:
- [http://api.joomla.org/](Joomla! API Reference)
- [http://tools.ietf.org/html/rfc5849](OAuth RFC)
Installation via Composer
Add "joomla/oauth1": "~3.0" to the require block in your composer.json and then run composer install.
{
"require": {
"joomla/oauth1": "~3.0"
}
}
Alternatively, you can simply run the following from the command line:
composer require joomla/oauth1 "~3.0"
joomla/oauth1 适用场景与选型建议
joomla/oauth1 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 330.39k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2013 年 10 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「joomla」 「oauth1」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 joomla/oauth1 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 joomla/oauth1 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 joomla/oauth1 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Etsy API OAuth 1.0 Client Provider for The PHP League OAuth1-Client
OAuth 1.0 Client Library for Goodreads
Joomla Preload Package
This project enables OAuth v1.0 and v2.0 in a simple yet effective way.
Laravel package for the simplification and integration of many of your users most wanted login providers. Installation is a breeze. Never worry about OAuth again.
统计信息
- 总下载量: 330.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 17
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2013-10-22