Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing env variables #28

Open
sinsedrix opened this issue Nov 4, 2019 · 7 comments
Open

Accessing env variables #28

sinsedrix opened this issue Nov 4, 2019 · 7 comments

Comments

@sinsedrix
Copy link

Hi,
I copied the .env.sample file to a .env.development one and added my github token to GITHUB_API_TOKEN.

But when I run gatsby develop, I still get the following error:

"gatsby-source-graphql" threw an error while running the sourceNodes lifecycle:
Response not successful: Received status code 401

In my browser, I still can't access the env variables (GITHUB_API_TOKEN and GATSBY_OG_APP_ID).

Am I meant to add some plugins like webpack / define to get gatsby-mail work?

@DSchau
Copy link
Owner

DSchau commented Nov 4, 2019

This line means that .env.development will be sourced.

Are you sure you created a token with the correct scopes required as per the README?

@sinsedrix
Copy link
Author

Yes, I have a token from onegraph with the app id.
In fact, I had the following error at first:

...\gatsby-mail\src\components\footer.js
61:11 error Cannot query field "github" on type "Query" graphql/template-strings

So I removed the github attribute from FooterQuery to see where the problem came from and saw the program couldn't join the graphql api.

@DSchau
Copy link
Owner

DSchau commented Nov 4, 2019

Right -- that error would be because the Github schema wasn't sourced (401) and so the github schema wasn't stitched in.

Could you paste your .env.development file with the secrets replaced?

@sinsedrix
Copy link
Author

Here it is:

# move this to .env.development to develop locally!
# conversely .env.production if building locally
GATSBY_OG_APP_ID=96a66e07-08c8-480e-b0f5-5c7617987ec3
# https://github.com/settings/tokens
GITHUB_API_TOKEN='xxx'

@DSchau
Copy link
Owner

DSchau commented Nov 4, 2019

And you've validated that GITHUB_API_TOKEN is in fact valid and has the right scopes right?

You can feel free to message me a zip of your project or something on Twitter (schaudustin) or e-mail at dustin @ gatsbyjs dot com

@sinsedrix
Copy link
Author

I created a personal token on https://github.com/settings/tokens and another on https://www.onegraph.com/. I don't know which one I'm meant to use or how to validate it. :/

@sinsedrix
Copy link
Author

You can feel free to message me a zip of your project or something on Twitter (schaudustin) or e-mail at dustin @ gatsbyjs dot com

I didn't change anything from your original repo, I just want to see how it works. The problem seems to be related to the access to env variables or the access to graphql.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants