lispa / amos-social-auth
社交认证
Requires
- php: >=5.4.0
- conquer/oauth2: *
- firebase/php-jwt: ^5.2.0
- google/apiclient: ^2.0
- hybridauth/hybridauth: ^3.1.1
- open20/amos-admin: ^2.7.4
- open20/amos-attachments: ^1.0
- open20/amos-core: ^1.23.0
- phpseclib/phpseclib: ^2.0.29
- yiisoft/yii2-authclient: ^2.1.0
- dev-master
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.0
- 1.9.0
- 1.8.1
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.1
- 1.6.0
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.7
- 1.1.6
- dev-releases/1.12.2
- dev-releases/1.12.1
- dev-releases/1.12.0
- dev-releases/1.11.0
- dev-releases/1.10.0
- dev-releases/1.9.0
- dev-releases/1.8.1
- dev-releases/1.8.0
- dev-releases/1.7.1
- dev-releases/1.7.0
- dev-releases/1.6.1
- dev-releases/1.6.0
- dev-releases/1.5.4
- dev-releases/1.5.3
- dev-releases/1.5.2
- dev-releases/1.5.1
- dev-releases/1.5.0
- dev-releases/1.4.0
- dev-releases/1.3.3
- dev-releases/1.3.2
- dev-releases/1.3.1
- dev-releases/1.3.0
- dev-releases/1.2.1
- dev-releases/1.2.0
- dev-releases/1.1.13
This package is auto-updated.
Last update: 2024-09-18 18:28:36 UTC
README
Amos 社交认证
安装
-
通过 composer 安装此扩展是首选方式。
运行以下命令之一
composer require open20/amos-social-auth
或
"open20/amos-social-auth": "~1.0"
将以下内容添加到您的
composer.json
文件的 require 部分。 -
将模块添加到您的 common 中的主配置
<?php 'modules' => [ 'socialauth' => [ 'class' => 'open20\amos\socialauth\Module' ], ],
-
应用迁移
php yii migrate/up --migrationPath=@vendor/open20/amos-social-auth/src/migrations
配置
-
示例配置
<?php 'modules' => [ 'socialauth' => [ 'class' => 'open20\amos\socialauth\Module', 'enableLogin' => true, 'enableLink' => false, 'enableRegister' => false, 'providers' => [ "Facebook" => [ "enabled" => true, "keys" => [ "id" => "", "secret" => "" ], "scope" => "email" ], "Twitter" => [ "enabled" => true, "keys" => [ "key" => "", "secret" => "" ], "scope" => 'email', "includeEmail" => true ], "Google" => [ "enabled" => true, "keys" => [ "id" => "", "secret" => "" ], "scope" => 'email', "includeEmail" => true ], ] ], ],
查看配置文档: https://hybridauth.github.io/hybridauth/userguide/Configuration.html
-
启用/禁用操作
enableLogin
允许社交登录enableLink
启用社交账户链接(my-profile '设置' 标签页)enableRegister
启用社交注册enableServices
列出与社交账户相关的已启用服务。默认情况下,数组包含calendar
和contacts
提供者链接功能在 '我的配置文件' 中管理。要启用社交链接,请检查管理员配置中社交账户框的可见性以及提供者按钮。
$modules['admin'] = [ 'class' => 'open20\amos\admin\AmosAdmin', 'enableRegister' => true, 'fieldsConfigurations' => [ 'boxes' => [ . . . 'box_social_account' => ['form' => true, 'view' => true], ], 'fields' => [ . . . 'facebook' => ['form' => true, 'view' => true, 'referToBox' => 'box_social_account'], 'google' => ['form' => true, 'view' => true, 'referToBox' => 'box_social_account'], 'linkedin' => ['form' => true, 'view' => true, 'referToBox' => 'box_social_account'], 'twitter' => ['form' => true, 'view' => true, 'referToBox' => 'box_social_account'], . . . ] ] ];
提供者
提供者配置文档: https://hybridauth.github.io/hybridauth/userguide.html 部分 '热门提供者'
- Google
(指南来自 https://hybridauth.github.io/hybridauth/userguide/IDProvider_info_Google.html)-
转到 Google 开发者控制台 https://console.developers.google.com/projectselector/apis/library?supportedpurview=project。
-
从项目下拉菜单中选择一个项目,或创建一个新的项目。
-
在 Google API 列表中启用 Google API 服务:搜索 Google+ API 服务。从结果列表中选择 Google+ API。点击启用 API 按钮。对 People API 和 Calendar API 也进行相同的操作
- 在 Google 控制台中启用 API
对于账户和联系人:People API,Google+ API
对于日历事件:Google Calendar API
- 在 Google 控制台中启用 API
-
过程完成后,已启用的 API 将出现在已启用 API 列表中。要访问,请从左侧侧边栏菜单中选择 API 管理员,然后选择已启用 API 选项卡。
-
在“API 管理员”下的侧边栏中,选择凭证。在凭证选项卡中,选择新的凭证下拉列表,并选择 OAuth 客户端 ID。
-
从应用程序类型列表中选择 Web 应用程序。
-
输入名称,并提供以下 URL 作为授权重定向 URI: https://YourPlatformUrl/socialauth/social-auth/sign-in?action=done&provider=google
https://YourPlatformUrl/socialauth/social-auth/sign-up?action=done&provider=google
https://YourPlatformUrl/admin/user-profile/enable-google-service -
注册完成后,将创建的应用程序凭证(客户端 ID 和密钥)复制并粘贴到 HybridAuth 配置文件中。
-