【发布时间】:2013-04-26 19:41:57
【问题描述】:
首先我想知道如何使用 oauth 工作。我们需要在这个插件中传递什么以及这个插件将返回什么。我们是否必须为不同的php框架定制插件。我已经看到它们是针对不同框架的 oauth 的不同扩展,这是为什么呢?
我需要在 yii 框架中对使用社交网络的用户进行身份验证,并且我已经集成了 yii 的 eouath 扩展以使用 oauth,并已采取行动来使用像这样访问 google 用户的广告服务
公共函数 actionGoogleAds() {
Yii::import('ext.eoauth.*');
$ui = new EOAuthUserIdentity(
array(
//Set the "scope" to the service you want to use
'scope'=>'https://sandbox.google.com/apis/ads/publisher/',
'provider'=>array(
'request'=>'https://www.google.com/accounts/OAuthGetRequestToken',
'authorize'=>'https://www.google.com/accounts/OAuthAuthorizeToken',
'access'=>'https://www.google.com/accounts/OAuthGetAccessToken',
)
)
);
if ($ui->authenticate()) {
$user=Yii::app()->user;
$user->login($ui);
$this->redirect($user->returnUrl);
}
else throw new CHttpException(401, $ui->error);
}
如果我想使用其他服务,如linkedin、facebook、twitter 来注册用户,我应该只是更改范围和参数,还是必须在其他地方进行一些更改。如何将用户信息存储在自己的数据库中?
【问题讨论】:
标签: oauth yii authentication