This is a follow up to Google Drive Realtime API OAuth2 Refresh Errors.
Since the update to the realtime API was pushed on Wednesday I've been seeing some additional issues with refreshing OAuth tokens. After the OAuth token expires, the realtime API gets a 401 error as expected and throw an error event on the document. This error is handled and the app requests a new OAuth token through gapi.auth.authorize which is successfully set in gapi.auth (verified using getToken). However, this token does not appear to be used by the realtime api which gets stacuk in a perpetual upload state but does not throw any errors.
>>>> 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 <<<<
Is this a know issue or is there a better way of handling this scenario? From what I can tell this is the correct way of handling the token refresh based on the previous posting linked at the top.