开发者

Google Oauth IMAP asking for permission everytime

I'm currently working on a web-based mail-service (it's not quite a mail-client but it's a lot to explain). However I've never worked with oauth before this but it seems like the way to go, I've based my simple classes on the sampel code. However the sample code doesn't provide the solution on signing in several times, or I've missed it.

So basically my problem is that everytime I log in I need to authorize to gmail again while I've seen other services where you do that once and after that you just sign in and get instantly redirected back without accepting again.

Edit: To clarify, I'm using oauth both for logging in and for IMAP, is this stupid? I though that was the best way as it seem weird to have both an OpenID and oauth connected to the same user when all my app really do is centered around google apps imap via oauth. I think that tungle.me works this way as I only have to authorize once there and the next time google instantly redirects me back, I want my app to work that way.

Edit2: After further searching it seems like authorization is for the first time and then I should use Authentication, as English isn't my first language I though they meant the same thing. So the questions stands, how to I authenticate with google when a user who've already created an account logs in开发者_如何学运维 again so that I won't need to generate new tokens every time.


require_once './oauth/apiClient.php';
require_once './oauth/contrib/apiPlusService.php';
$client = new apiClient();
$client->setApplicationName("Name");
$client->setScopes(array('https://www.googleapis.com/auth/plus.me'));
$client->setApprovalPrompt (auto);

... the last one solves the problem, since by default apiClient sets approval_prompt to "force"

Hope this helps someone


Using the google API you can turn a 1 time auth cookie into a permanent auth cookie. If you store this new permanent auth cookie in a database or somewhere, you can use it for that specific user instead of generating a new auth cookie each time.

Something like this:

$client = new Zend_Gdata_HttpClient();
$client->setAuthSubPrivateKeyFile('key.pem', null,false);
$uri = Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session)
$gCalToken = Zend_Gdata_AuthSub::getAuthSubSessionToken(trim($uri),$client);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜