2

Google photos recently made a change to their API (I think), on August 1st. They changed the Listing Library Contents from a POST to a GET. And now my code no longer works. https://developers.google.com/photos/library/guides/list

Here is a snapshot of the code:

payload = {"pageSize" : "500", "pageToken" : parsed_json['nextPageToken']}
#payload = {"pageSize" : "500"}
#payload = {"pageToken" : parsed_json['nextPageToken']}
myResponse = requests.get('https://photoslibrary.googleapis.com/v1/mediaItems', headers={"Content-type" : "application/json", "Authorization" : "Bearer " + credentials.access_token}, params=payload)
parsed_json = json.loads(myResponse.content)

This code gives me an error: "error": { "code": 400, "message": "Request contains an invalid argument.", "status": "INVALID_ARGUMENT" }

It seems that if I pass two params to the GET request, I get the error. But if I pass only one param to the GET request, either the pageSize or the pageToken, it works fine. (that code is also included but commented out).

This worked fine until Aug 1 when I think google made a change.

Given I am a new programmer, I feel I am missing something key here, but I cannot figure out what it is at all.

Any help would be much appreciated!

awightma
  • 41
  • 1
  • I just wanted to let you know that I have the same issue in my Android App. This should be a change from Google as you suggested. – Quentin Menini Aug 08 '18 at 08:38

1 Answers1

0

I think I figured out what your problem is. There is a sentence in the documentation saying : "The nextPageToken is only valid for the same request. If any parameters are changed, a previously used nextPageToken shouldn't be used in the same request."

I had the same issue you have because the first pageSize I loaded was 500 and then I wanted to load pages of 200 items (to have a smoother scroll). It worked at first but then there was a change and it didn't work anymore (INVALID_ARGUMENT).

Maybe you have this issue because the first GET you made (the one that gave you the token) didn't have the same pageSize as the one you are making with the token.

By the way, I still use the POST to list library content as I would load album content, without providing an albumId and it seems to work fine.

Quentin Menini
  • 160
  • 1
  • 1
  • 12