Download the PHP package shopwwi/webman-socialite without Composer

On this page you can find all versions of the php package shopwwi/webman-socialite. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package webman-socialite

webman-socialite

webman-socialite 是一个 OAuth2 社会化认证工具。 它借鉴于 laravel/socialite ,你可以轻易的运行在webman的laravel/tp/yii等项目中使用它

'Latest Stable Version' 'Total Downloads' 'License'

该工具现已支持平台有:Facebook,Github,Google,Linkedin,Outlook,QQ,TAPD,支付宝,淘宝,百度,钉钉,微博,微信,抖音,飞书,Lark,豆瓣,企业微信,腾讯云,Line,Gitee,Coding。

如果你觉得方便了你,可以为我点个小星星点击这里 :heart:

安装

配置

在使用 Socialite 之前,您还需要为应用程序使用的 OAuth 服务添加凭据。 这些凭证应该放在你的 config/plugin/shopwwi/socialite/app.php 配置文件中,并且应该使用密钥 facebook,twitter,linkedin,google,github,gitlab 或 bitbucket, 取决于您的应用程序所需的提供商。 例如:

使用方法

接下来,就要对用户认证了!这需要两个路由:一个路由用于把用户重定向到 OAuth provider,另一个则用于在认证完成后接收相应 provider 的回调请求。可以通过 Socialite facade 的方式来访问 Socialite:

配置

扩展自定义服务提供程序

你可以很轻松的对socialite进行扩展来满足你不同的第三方登入需求

1.直接在config配置里添加你的应用驱动

2.使用闭包函数进行扩展

3.接下来为 AppleProvider 设置实际操作方法:

你的自定义服务提供类必须实现\Shopwwi\WebmanSocialite\Contracts\Provider 接口

下面的示例继承了 \Shopwwi\WebmanSocialite\Providers\AbstractProvider 大多数逻辑都是实现好了的 微调即可

平台

不同的平台有不同的配置方法,为了确保工具的正常运行,所以请确保你所使用的平台的配置都是如期设置的。

支付宝

请按如下方式配置

钉钉

如文档所示

注意:该工具仅支持 QR code 连接到第三方网站,用来获取用户信息(openid, unionid 和 nickname)

抖音

头条

西瓜

百度

其他配置没啥区别,在用法上,可以很轻易的选择重定向登录页面的模式,通过 withDisplay()

popup 模式是工具内默认的使用模式。basic 是默认使用的 scopes 值。

飞书

通过一些简单的方法配置 app_ticket 就能使用内部应用模式

Lark

通过一些简单的方法配置 app_ticket 就能使用内部应用模式

淘宝

其他配置与其他平台的一样,你能选择你想要展示的重定向页面类型通过使用 withView()

web 模式是工具默认使用的展示方式, user_info 是默认使用的 scopes 范围值。

微信

我们支持开放平台代表公众号进行第三方平台网页授权。

你只需要像下面这样输入你的配置。官方账号不需要授权。

Coding

您需要额外配置 team_url 为您的团队域名

其他一些技巧

访问作用域

在重定向用户之前,你还可以使用 scopes 方法在请求中添加其他「作用域」。此方法将覆盖所有现有的作用域:

回调链接

你也可以动态设置 redirect_uri ,你可以使用以下方法来改变 redirect_uri URL:

State

你的应用程序可以使用一个状态参数来确保响应属于同一个用户发起的请求,从而防止跨站请求伪造 (CSFR) 攻击。当恶意攻击者欺骗用户执行不需要的操作 (只有用户有权在受信任的 web 应用程序上执行) 时,就会发生 CSFR 攻击,所有操作都将在不涉及或警告用户的情况下完成。

这里有一个最简单的例子,说明了如何提供状态可以让你的应用程序更安全。在本例中,我们使用会话 ID 作为状态参数,但是您可以使用您想要为状态创建值的任何逻辑。

带着 state 参数的重定向

检验回调的 state

一旦用户授权你的应用程序,用户将被重定向回你的应用程序的 redirect_uri。OAuth 服务器将不加修改地返回状态参数。检查 redirect_uri 中提供的状态是否与应用程序生成的状态相匹配:

查看更多关于 state 参数的文档

可选参数

许多 OAuth providers 支持重定向请求中的可选参数。 要在请求中包含任何可选参数,请使用关联数组调用 with 方法:

返回用户信息

标准的 user api:

你可以像这样以数组键的形式获取 user 属性:

或者使用该 User 对象的方法:

从 OAuth API 响应中取得原始数据

$user->getRaw() 方法会返回一个 array

当你使用 userFromCode() 想要获取 token 响应的原始数据

$user->getTokenResponse() 方法会返回一个 array 里面是响应从获取 token 时候 API 返回的响应。

注意:当你使用 userFromCode() 时,这个方法只返回一个 有效的数组,否则将返回 null,因为 userFromToken() 没有 token 的 HTTP 响应。

通过 access token 获取用户信息

参照

License

MIT


All versions of webman-socialite with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2|^8.0
ext-json Version *
guzzlehttp/guzzle Version ^6.0|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package shopwwi/webman-socialite contains the following files

Loading the files please wait ....