I am trying to call the GitHub GraphQL API using Clerk's GitHub authentication on Next.js. After the user logged in via GitHub (which works flawlessly), the API call to the GitHub GraphQL API is made. This is what the decoded Authorization header of that request looks like (I replaced non-relevant data with 'abc' for security reasons):
{
"azp": "http://localhost:3000",
"email": "{{user.email}}",
"exp": abc,
"github": {
"access_token": "{{user.external_accounts.github.access_token}}"
},
"iat": abc,
"iss": "abc",
"jti": "abc",
"name": "abc",
"nbf": abc,
"sub": "abc"
}
Seems like the variables aren't... getting recognised as variables?
This is the JWT template:
{
"name": "{{user.first_name}} {{user.last_name}}",
"email": "{{user.email}}",
"github": {
"access_token": "{{user.external_accounts.github.access_token}}"
}
}
And this is the relevant part of the code:
const query = `
query {
viewer {
repositories(first: 100, ownerAffiliations: OWNER, isFork: false) {
nodes {
name
description
stargazerCount
url
}
}
}
}
`;
const response = await fetch(";, {
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ query }),
});
I've been trying around for days now, reading through Clerk & GitHub docs, tried around with variable names and double-checked everything but can't seem to find a solution. Did someone already encouter similar issues or even knows a solution to this? Thank you so much!