Duke Sanmi
Duke Sanmi

Reputation: 67

Github GraphQL API Authentication

I want to retrieve data from github's graphql api but I keep getting error message: { message: 'This endpoint requires you to be authenticated.', documentation_url: 'https://docs.github.com/v3/#authentication' } Despite using a token, I even generated a new token to see if the other one was broken. The script to fetch the data can be found at https://repl.it/@DukeSanmi/AcrobaticModernLanguage#index.js What could be the issue?

Upvotes: 1

Views: 1154

Answers (1)

evangineer
evangineer

Reputation: 417

Okay you need to put a space between bearer and your variables.githubToken like so:

const headers = {
    'Content-Type': 'application/json',
    'Authorization': 'bearer ' + variables.githubToken
};

Furthermore, NEVER publish secrets/credentials like API tokens in public code!

Upvotes: 5

Related Questions