serenity_technologies/socialite-ctrader
Composer 安装命令:
composer require serenity_technologies/socialite-ctrader
包简介
cTrader Socialite Provider for Laravel Socialite.
README 文档
README
This is a cTrader Socialite provider for Laravel Socialite.
Installation
You can install the package via composer:
composer require serenity_technologies/socialite-ctrader
The package requires the google/protobuf library to communicate with the cTrader Open API binary protocol.
Configuration
Add the configuration to your config/services.php file:
'ctrader' => [ 'client_id' => env('CTRADER_CLIENT_ID'), 'client_secret' => env('CTRADER_CLIENT_SECRET'), 'redirect' => env('CTRADER_REDIRECT_URI'), ],
Registration
You will need to register the provider using the SocialiteExtendSocialite event. Add the listener to your app/Providers/EventServiceProvider.php:
protected $listen = [ \SocialiteProviders\Manager\SocialiteWasCalled::class => [ \SocialiteProviders\Ctrader\CtraderExtendSocialite::class.'@handle', ], ];
Usage
You can now use the provider like any other Socialite provider:
use Laravel\Socialite\Facades\Socialite; // Redirect to cTrader for authorization return Socialite::driver('ctrader')->redirect(); // Receive the callback from cTrader $user = Socialite::driver('ctrader')->user(); // Access user details $userId = $user->getId(); $email = $user->getEmail(); // Generated as {userId}@ctrader.com $token = $user->token;
Scopes
By default, the provider uses the accounts scope. You can change this or add more scopes:
return Socialite::driver('ctrader') ->scopes(['trading']) ->redirect();
User Profile Retrieval
Unlike many other Socialite providers, cTrader does not provide a standard REST endpoint for user profile information. This provider automatically handles this by:
- Exchanging the authorization code for an access token via REST.
- Connecting to the cTrader Open API gateway via an SSL TCP socket.
- Sending a
ProtoOAGetCtidProfileByTokenReqmessage to retrieve the unique cTrader User ID. - Mapping this ID to the Socialite User object and generating a
{userId}@ctrader.comemail address.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-13