Monday, 15 July 2013

google drive sdk - How does one one avoid 404's on changes.list thumbnails when signed in with multiple accounts? -



google drive sdk - How does one one avoid 404's on changes.list thumbnails when signed in with multiple accounts? -

i getting 404's image thumbnails when i'm signed on multiple accounts , making api calls changes.list.

the total steps reproduce issue described below:

be signed in 2 accounts, 1 personal gmail account, , 1 google apps account, user_gmail , user_gapps respectively

make api calls urls list of changes in drive.

load thumbnails images.

expected behaviour:

thumbnail images work.

actual behaviour:

when signed in user_gmail , user_gapps , pick user_gmail during authentication flow, can see thumbails modified documents.

when signed in user_gapps or user_gmail, can see thumbnails correctly.

however, when signed in both users, , pick user_gapps user during authentication flow, see broken thumbnails.

update: easiest way reproduce sign multiple accounts, 1 personal , 1 apps account, , utilize api. if authorize api work account, , execute request, , click on "thumbnaillink" urls, can see 404s.

https://developers.google.com/apis-explorer/#p/drive/v2/drive.changes.list?includedeleted=false

there 2 ways see google document's thumbnail. after getting url of thumbnail through google drive api url can viewed using either 'cookie' authorization or oauth 2.0 authorization.

you seem using 'cookie' authorization (i.e. user signed in browser). happens browser utilize 1 of 2 accounts default , unfortunately might not utilize right account. in specific scenario can append &authuser=0 or &authuser=1 url of thumbnail forcefulness using business relationship or other, 1 of 2 values work.

the issue don't know value work (1 or 0) have test 2 urls programmatically using javascript see 1 works or fails.

the other way load thumbnail utilize oauth 2 auth. more robust. can appending &access_token=<your_oauth_2_access_token>. create sure utilize same oauth access token (formerly known bearer token) used in api requests. way sure image load. work if user has signed-out of google account. need access actual file's data. won't work if have authorized drive.readonly.metadata scope instance. need authorize 1 of next scopes:

https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.readonly

just beware: access tokens valid 1h.

google-drive-sdk

No comments:

Post a Comment