Google Drive API downloadURL 401 error

google-drive-api

272 просмотра

1 ответ

1 Репутация автора

Anybody can help or enlighten me with my issue:

I'm a Java developer and I have an existing smart printer app called GDrive App. It uses Google Drive API (oauth 2.0, gdata-version 2.0 and 3.0 for download-print file) .

This has been working for months until now. Actually, only the download-printing part is no longer working this time, I can still access the app (retrieve files, create folder, search and delete files).

Actual problem: I keep on getting 401 error when I try to download file (to input stream) for printing. It's confusing because I already provided all the necessary information during the request. And it has been working for many months. No changes of the code. Weird.

I have this for headers: [Authorization: Bearer ya29.CjAkA8uPBUsKWYMSEDpPxUbP_vtQJOKfCZ7O8I4GkpUkN70bGgnDTAVYiVW2m353H2Y , GData-Version: 3.0 ]

While executing this URL to download and print resource, I couldn't access this.

https://doc-0o-7o-docs.googleusercontent.com/docs/securesc/l9c2gms12ko7qqfc58putbb2v38kkvmm/dp5l9kmpu48kdi8mp2rvtmc1dm1f41tk/1468828800000/09859633411849852329/09859633411849852329/0ByU-nFK_03gtZGhBZkxCYmExeGc?e=download&gd=true

Автор: Johan Magos Источник Размещён: 18.07.2016 01:24

Ответы (1)


0 плюса

514 Репутация автора

Error 401 means that you aren't authorized properly. Most likely the ya29.CjAkA8uPBUsKWYMSEDpPxUbP_vtQJOKfCZ7O8I4GkpUkN70bGgnDTAVYiVW2m353H2Y access token you are using expired and you have to request another.

You should write your code to anticipate the possibility that a granted token might no longer work. A token might stop working for one of these reasons:

  • The user has revoked access.
  • The token has not been used for six months.
  • The user changed passwords and the token contains Gmail, Calendar, Contacts, or Hangouts scopes.
  • The user account has exceeded a certain number of token requests.

source

You can use GoogleAuthorizationCodeTokenRequest to request an access token and possibly a refresh token.

Автор: PockeTiger Размещён: 18.07.2016 01:35
Вопросы из категории :
32x32