Android Proxy: debug token scopes for android enterprise creation (#35237)

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Attempt at debugging #34776 

Another attempt to further debug this issue. This attempt tries to
verify that the scopes for the token is correct, and is not overriden by
another call to the scopes.

The reason is that the `www-authenticate` response header is saying
`error="insufficient_scope"`
This commit is contained in:
Magnus Jensen
2025-11-06 11:14:42 -03:00
committed by GitHub
parent 516f34d183
commit da27c3f08b
@@ -91,6 +91,15 @@ module.exports = {
}
});
// Debugging case: Log the actual token scopes in use.
const accessTokenObj = await authClient.getAccessToken();
const rawToken = accessTokenObj.token || accessTokenObj; // depending on version
// eslint-disable-next-line no-undef
const tokenInfoRes = await fetch(`https://oauth2.googleapis.com/tokeninfo?access_token=${rawToken}`);
const tokenInfo = await tokenInfoRes.json();
sails.log.debug('Token scopes actually in use:', tokenInfo.scope);
// [?]: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/getIamPolicy
// Retrieve the IAM policy for the created pubsub topic.
// !IMPORTANT: This should not be wrapped in a sails.helpers.flow.build, as we've seen issues with it not working properly.