Comments (10)
please check https://github.com/leo108/php_cas_server_oauth_weibo for reference
from php_cas_server.
php_cas_server_oauth_weibo I have installed.
config/app.php
'providers' => [
....
Leo108\CASServer\OAuth\Weibo\CASOAuthWeiboServiceProvider::class,
],
app/Interactions/UserLogin.php
public function showLoginPage(Request $request, array $errors = [])
{
dd(app(PluginCenter::class)->getAll());
return view(
'auth.login',
[
'errorMsgs' => $errors,
'plugins' => app(PluginCenter::class)->getAll(),
'service' => $request->get('service', null),
]
);
}
Result on browser
[]
from php_cas_server.
Put this code in App\Providers\AppServiceProvider::register
$this->app->bind(
'cas.server.weibo',
function () {
return (new Overtrue\Socialite\SocialiteManager(
[
'weibo' => [
'client_id' => 'your-app-id',
'client_secret' => 'your-app-secret',
],
]
))->driver('weibo');
}
);
run
php artisan vendor:publish --provider="Leo108\CASServer\OAuth\Weibo\ CASOAuthWeiboServiceProvider" --tag="migrations"
and
php artisan migrate
from php_cas_server.
Socialite requires a "redirect", if not provided, an error will occur.
1/1
ErrorException in SocialiteManager.php line 240:
Undefined index: redirect
in SocialiteManager.php line 240
at HandleExceptions->handleError('8', 'Undefined index: redirect', '/home/lijiahao/Code/php_cas_server/vendor/overtrue/socialite/src/SocialiteManager.php', '240', array('config' => array('client_id' => 'your-app-id', 'client_secret' => 'your-app-secret'))) in SocialiteManager.php line 240
at SocialiteManager->formatConfig(array('client_id' => 'your-app-id', 'client_secret' => 'your-app-secret')) in SocialiteManager.php line 150
at SocialiteManager->createDriver('weibo') in SocialiteManager.php line 109
at SocialiteManager->driver('weibo') in AppServiceProvider.php line 70
at AppServiceProvider->App\Providers\{closure}(object(Application), array()) in Container.php line 731
at Container->build(object(Closure), array()) in Container.php line 629
at Container->make('cas.server.weibo', array()) in Application.php line 697
at Application->make('cas.server.weibo') in CASOAuthWeiboServiceProvider.php line 51
at CASOAuthWeiboServiceProvider->checkBound('cas.server.weibo', 'Overtrue\Socialite\Providers\AbstractProvider') in CASOAuthWeiboServiceProvider.php line 25
at CASOAuthWeiboServiceProvider->register() in Application.php line 554
at Application->register(object(CASOAuthWeiboServiceProvider)) in ProviderRepository.php line 74
at ProviderRepository->load(array('Illuminate\Auth\AuthServiceProvider', 'Illuminate\Broadcasting\BroadcastServiceProvider', 'Illuminate\Bus\BusServiceProvider', 'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 'Illuminate\Cookie\CookieServiceProvider', 'Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Encryption\EncryptionServiceProvider', 'Illuminate\Filesystem\FilesystemServiceProvider', 'Illuminate\Foundation\Providers\FoundationServiceProvider', 'Illuminate\Hashing\HashServiceProvider', 'Illuminate\Mail\MailServiceProvider', 'Illuminate\Pagination\PaginationServiceProvider', 'Illuminate\Pipeline\PipelineServiceProvider', 'Illuminate\Queue\QueueServiceProvider', 'Illuminate\Redis\RedisServiceProvider', 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 'Illuminate\Session\SessionServiceProvider', 'Illuminate\Translation\TranslationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'App\Providers\AppServiceProvider', 'App\Providers\AuthServiceProvider', 'App\Providers\EventServiceProvider', 'App\Providers\RouteServiceProvider', 'Fideloper\Proxy\TrustedProxyServiceProvider', 'Leo108\CAS\CASServerServiceProvider', 'Leo108\CASServer\OAuth\Weibo\CASOAuthWeiboServiceProvider')) in Application.php line 530
at Application->registerConfiguredProviders() in RegisterProviders.php line 17
at RegisterProviders->bootstrap(object(Application)) in Application.php line 203
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 232
at Kernel->bootstrap() in Kernel.php line 127
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53
at require_once('/home/lijiahao/Code/php_cas_server/public/index.php') in server.php line 21
At present I write like this to fix the issue, is there a better way to get this redirect route?
$this->app->bind(
'cas.server.weibo',
function () {
return (new SocialiteManager(
[
'weibo' => [
'client_id' => 'your-app-id',
'client_secret' => 'your-app-secret',
'redirect' => "oauth/" . $this->app->make(WeiboPlugin::class)->getFieldName() . "/callback",
],
]
))->driver('weibo');
}
);
from php_cas_server.
@rikakomoe just set redirect
to an empty string should fix this problem, we will call redirect()
method with final callback url here.
from php_cas_server.
That doesn't work.
The request in Leo108\CASServer\OAuth\Weibo\Plugins\WeiboPlugin::getOAuthUser requires a "redirect_uri" too, otherwise you get an error like this,
1/1
AuthorizeFailedException in AbstractProvider.php line 439:
Authorize Failed: {"error":"redirect_uri_mismatch","error_code":21322,"request":"\/2\/oauth2\/access_token","error_uri":"\/2\/oauth2\/access_token"}
in AbstractProvider.php line 439
at AbstractProvider->parseAccessToken(object(Stream)) in AbstractProvider.php line 264
at AbstractProvider->getAccessToken('ea6a206c387abdb7e44fa82659b2890d') in AbstractProvider.php line 185
at AbstractProvider->user() in WeiboPlugin.php line 51
at WeiboPlugin->getOAuthUser(object(Request)) in OAuthController.php line 54
at OAuthController->callback('weibo_id', object(Request))
However by no means could this redirect uri be figured out. I guess it is some design issue with Leo108\CASServer\OAuth\Plugin::getOAuthUser, which should probably request a parameter "callback" too. Or maybe there are better ways instead?
from php_cas_server.
@rikakomoe yes you are right, add a callback
parameter to getOAuthUser
method is a solution, I'll handle this.
from php_cas_server.
@rikakomoe fixed at 151dd48 , thanks for your reporting.
from php_cas_server.
@leo108 Please also update these two packages to avoid broken dependencies.
https://github.com/leo108/php_cas_server_oauth_weibo/blob/592d659534d3ab1895c4eb826eeff2af250e74a4/composer.json#L20
https://github.com/leo108/php_cas_server_oauth_wechat/blob/89d17c8d2d95e97672f3f26a5e3f0061dd420410/composer.json#L21
from php_cas_server.
@rikakomoe just forgot to push, done
from php_cas_server.
Related Issues (20)
- 想增加对手机号登录的支持,请指点。 HOT 3
- Getting attributes HOT 2
- SLO. Is there feature that sends logout request to all clients? HOT 2
- Setting User HOT 3
- 服务端session过期,客户端不能正常登出 HOT 3
- 编译环境标识不清楚 HOT 1
- Can use PgSQL?? HOT 7
- Error in helpers.php when installing on Windows ampps HOT 6
- Question about service login
- 请问redis配置支持集群吗? HOT 1
- LOG
- URL for service
- 如何单点退出 HOT 1
- Support for cas-attribute HOT 1
- Error on running gulp HOT 1
- npm install Error HOT 2
- gulp error
- php artisan migrate error HOT 1
- Please help me, run gulp watch exception HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php_cas_server.