in src/libs/identity.ts [20:70]
async function queryUserDetailsFromIdAPI(
identityId: string,
identityAPIBearerToken: string,
): Promise<IdAPIUserConsent> {
//console.log(
// `Querying IdAPI for identityId ${identityId} with token ${identityAPIBearerToken}`,
//);
console.log(`Querying IdAPI for identityId ${identityId}`);
const url = `https://idapi.theguardian.com/user/${identityId}`;
//console.log(`url: ${url}`);
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Bearer ${identityAPIBearerToken}`,
},
});
/*
response.data is a
{
"status": "ok",
"user": {
"primaryEmailAddress": "[REMOVED]",
"id": "[REMOVED]",
"publicFields": {
"displayName": "user"
},
"dates": {
"accountCreatedDate": "2018-12-03T10:22:45Z"
},
"consents": [
[....],
{
"actor": "user",
"id": "phone_optout",
"version": 0,
"consented": false,
"timestamp": "2018-12-03T10:22:45Z",
"privacyPolicyVersion": 1
}
],
"hasPassword": true
}
}
*/
return (await response.json()) as IdAPIUserConsent;
}