arter / amos-social-auth
社交认证
该软件包的官方仓库似乎已不存在,因此该软件包已被冻结。
Requires
- php: >=5.4.0
- arter/amos-admin: ^2.0.18
- arter/amos-attachments: ^1.0
- arter/amos-core: ^1.9.52
- conquer/oauth2: *
- google/apiclient: ^2.0
- hybridauth/hybridauth: ~2.9
- yiisoft/yii2-authclient: ^2.1.0
This package is auto-updated.
Last update: 2024-06-16 20:07:54 UTC
README
Amos 社交认证
安装
安装此扩展的首选方式是通过 composer。
运行
composer require arter/amos-social-auth
或添加
"arter/amos-social-auth": "~1.0"
到您的
composer.json
文件的 require 部分。将模块添加到您的 common 主配置文件中
<?php 'modules' => [ 'socialauth' => [ 'class' => 'arter\amos\socialauth\Module' ], ],
应用迁移
php yii migrate/up --migrationPath=@vendor/arter/amos-social-auth/src/migrations
配置
示例配置
<?php 'modules' => [ 'socialauth' => [ 'class' => 'arter\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 'settings' 选项卡)enableRegister
启用使用社交的注册enableServices
列出与社交账户相关的已启用服务。默认情况下,数组包含calendar
和contacts
提供者链接功能在 'My Profile', amos-admin 中管理。要启用社交链接,请检查管理员配置中 social-accounts 框的可见性以及提供者按钮。
$modules['admin'] = [
'class' => 'arter\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 服务。从结果列表中选择 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 配置文件中。