googleworkspace / googleworkspace/apps-script-samples

getLicenseAssignments pageToken returns null value

Open
#193 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.2k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

Expected Behavior

getLicenseAssignments should return all the users in the specified domain. PageToken should be populated to allow calling more than 500 results.

url: https://github.com/googleworkspace/apps-script-samples/blob/master/advanced/adminSDK.gs

Actual Behavior

getLicenseAssignments only returns the first page and the PageToken value is null. Also, the while(pageToken) is on the wrong line. It is currently on line 212 and should be on line 220.

Steps to Reproduce the Problem

  1. Call getLicenseAssignments and request 500 as the max result. Assuming there are more than 500 users, you should get a list of 500 users.
  2. Change maxResults to 1 and you should only get one result and pagetoken is null.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open advanced/adminSDK.gs and inspect getLicenseAssignments, especially the pagination logic around lines 212 and 220. Reproduce the issue with maxResults set to 1 and verify that results beyond the first page can be retrieved and that pageToken is populated when more users remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.