2012-05-17 56 views
0

我正在運行dredit示例,第一次啓動應用程序時sql表爲空,並且應用程序插入一個值,所有運行正常,但我截斷了表,現在'refresh_token'爲null,應用程序崩潰。爲什麼現在是空的?與firts時間運行的情況不一樣嗎?爲什麼截斷崩潰auth?Google驅動器oauth令牌錯誤

[15-May-2012 22:56:59] Error when authenticating and authorizing user: Error fetching OAuth2 access token, message: 'invalid_grant'

[15-May-2012 22:57:00] Error retrieving user from DB or updating refresh token: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'refresh_token' cannot be null

[15-May-2012 22:57:00] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'refresh_token' cannot be null' in /var/www/drivecrypt/www/auth_handler.php:214

Stack trace:

#0 /var/www/drivecrypt/www/auth_handler.php(214): PDOStatement->execute()

#1 /var/www/drivecrypt/www/auth_handler.php(244): AuthHandler->CreateUserInDb(Object(Userinfo), NULL)

#2 /var/www/drivecrypt/www/auth_handler.php(293): AuthHandler->GetUser(Object(Userinfo), NULL)

#3 /var/www/drivecrypt/www/index.php(48): AuthHandler->VerifyAuth() #4 {main}

thrown in /var/www/drivecrypt/www/auth_handler.php on line 214

+0

[Google drive dredit token error]可能的重複(http://stackoverflow.com/questions/10610016/google-drive-dredit-token-error) – Jeremy

+0

你能解釋爲什麼你截斷了表嗎?你做了什麼(你在哪裏截斷它?) – Nivco

+0

我也遇到了這個問題,我嘗試進行身份驗證,我從來沒有從API獲取刷新令牌。 – Dustin

回答

0

您應該在AuthHandler-> GetUserFromDb中捕獲異常並將null返回給AuthHandler-> GetUser。但是,通過這樣做,它將在會話中使用空的刷新令牌創建新的用戶條目,並且隨後的請求將失敗,出現401。

要解決此問題,您需要確保$ _SESSION ['credentials' ]在您到達https://code.google.com/p/google-drive-sdk-samples/source/browse/php/auth_handler.php#335時未設置,以便用戶將被重定向到OAuth授權頁面並再次授予訪問權限以請求新的刷新令牌。