这是Google Drive Realtime API OAuth2 Refresh Errors的后续行动。
由于周三推出了对实时API的更新,因此我一直在看到刷新OAuth令牌的其他一些问题。 OAuth令牌过期后,实时API会按预期获得401错误,并在文档上引发错误事件。处理此错误,应用程序通过gapi.auth成功设置的gapi.auth.authorize请求新的OAuth令牌(使用getToken验证)。但是,这个令牌似乎没有被实时api使用,它使stacuk处于永久上传状态,但不会引发任何错误。
>>>> Page Load <<<<
1374822961806 ": GAPI Authorized"
Object {state: "", access_token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_DloepHbGho", token_type: "Bearer", expires_in: "3600", client_id: "XXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com"…}
_aa: "1"
access_token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_DloepHbGho"
client_id: "XXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com"
cookie_policy: undefined
expires_at: "1374826561"
expires_in: "3600"
g_user_cookie_policy: undefined
issued_at: "1374822961"
response_type: "token"
scope: Array[2]
state: ""
token_type: "Bearer"
>>>> Document loaded successfully <<<<
Remote Size: 130.24 kB
Remote String Size: 22.01 kB
Final Remote Item Counts:
Map : 409
List : 118
EditableString : 407
Total Inaccessible Items: 8
Total Unused Lists: 14
>>>> Wait for OAuth2 Token Timeout <<<<
GET https://drive.google.com/otservice/bind?id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX…RID=rpc&SID=XXXXXXXXXXXXXXXXXXXXXXXXXXX&CI=0&AID=206&TYPE=xmlhttp&zx=7cirt7mulog0&t=1 401 (Unauthorized) api:87
Drive Realtime API Error: token_refresh_required: The OAuth token must be refreshed. api:477
Doc Load Error: Sx {type: "token_refresh_required", message: "The OAuth token must be refreshed.", b: false, isFatal: false}
>>>> Handle Doc Load Error <<<<
1374826571645 ": Refreshing OAuth2 Token: "
["https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/userinfo.email"]
>>>> Before refreshing call gapi.auth.getToken() <<<<
1374826571646 ": Current Token: " null
>>>> Refresh using gapi.auth.authorize() and do NOT call gapi.auth.setToken() <<<<
1374826571813 ": Refreshed OAuth2 Token: "
Object {state: "", access_token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_qnWk1NXWXHCmi", token_type: "Bearer", expires_in: "3600", client_id: "XXXXXXXXXXXXXXXXXX.apps.googleusercontent.com"…}
_aa: "1"
access_token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_qnWk1NXWXHCmi"
client_id: "XXXXXXXXXXXXXXX.apps.googleusercontent.com"
cookie_policy: undefined
expires_at: "1374830171"
expires_in: "3600"
g_user_cookie_policy: undefined
issued_at: "1374826571"
response_type: "token"
scope: Array[2]
state: ""
token_type: "Bearer"
>>>> After refreshing call gapi.auth.getToken() <<<<
1374826571814 ": New Token: "
Object {state: "", access_token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_qnWk1NXWXHCmi", token_type: "Bearer", expires_in: "3600", client_id: "XXXXXXXXXXXXXXXXXX.apps.googleusercontent.com"…}
_aa: "1"
access_token: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_qnWk1NXWXHCmi"
client_id: "XXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com"
cookie_policy: undefined
expires_at: "1374830171"
expires_in: "3600"
g_user_cookie_policy: undefined
issued_at: "1374826571"
response_type: "token"
scope: Array[2]
state: ""
token_type: "Bearer"
>>>> At this point the document is stuck in isPending and isSaving <<<<
>>>> Modifications to the document don't error but don't persist <<<<
这是一个已知问题还是有更好的方法来处理这种情况?据我所知,这是根据在顶部链接的先前帖子处理令牌刷新的正确方法。