The code works fine. I didn't realize that the nextPageToken for each successive call is the same as the last call ie. when you loop through the fetching of data, nextPageToken stays the same; it only becomes nil on the last fetch.