rwaldron / particle-io

Particle/Spark Core/Photon IO Plugin for Johnny-Five
http://johnny-five.io
MIT License
173 stars 31 forks source link

.sparkrc #42

Closed auch188 closed 9 years ago

auch188 commented 9 years ago

Hi

Sorry to open an issue, but I am stuck with the part where you create the .sparkrc file. I'm trying to get D7 to blink in my spark core with the spark-io plugin.

I flashed my spark core with the voodooSpark firmware. Then I created the .sparkrc file with my spark core token and device id and get the following error;

Error: Unable to connect to spark cloud.: code: 400 { "code": 400, "error": "invalid_grant", "error_description": "The access token provided is invalid." } at IncomingMessage. (/home/phil/Documents/Spark/Hello World/node_modules/spark-io/lib/spark.js:243:19) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:929:16 at process._tickCallback (node.js:419:13)

also console.log(process.env.SPARK_TOKEN) gives an output of undefined.

Please help

Resseguie commented 9 years ago

Did you source the .sparkrc file?

source .sparkrc

That actually loads the variables into your environment so they can be accessed inside of Node.js via process.env

If you put that into your shell's dotfile, note that it will be loaded automatically for you the next time you open a new terminal window.

Certainly let us know if you still have problems and we can help you along. Or if you just want to move past it and "get it working" you can always copy the access tokens directly into the Spark-io constructor in your code in place of the two process.env references.

Feel free to join us on Gitter chat for help like this anytime! https://gitter.im/rwaldron/johnny-five

@rwaldron next time one of us updates the README, we should probably clarify this a bit more in the Getting Started section: https://github.com/rwaldron/spark-io#getting-started

auch188 commented 9 years ago

Do you source the .sparkrc file in a seperate file? If so what do you name it as?

I tried to put "source .sparkrc" in my HelloWorld.js code but it produced a compile error.

On Sat, Nov 22, 2014 at 2:03 AM, David Resseguie notifications@github.com wrote:

Did you source the .sparkrc file?

source .sparkrc

That actually loads the variables into your environment so they can be accessed inside of Node.js via process.env

Certainly let us know if you still have problems and we can help you along. Or if you just want to move past it and "get it working" you can always copy the access tokens directly into the Spark-io constructor in your code in place of the two process.env references.

Feel free to join us on Gitter chat for help like this anytime! https://gitter.im/rwaldron/johnny-five

— Reply to this email directly or view it on GitHub https://github.com/rwaldron/spark-io/issues/42#issuecomment-63981670.

auch188 commented 9 years ago

I finally got it working. I misunderstood and thought I needed to put the "source .sparkrc" command into a file. I put the command in the terminal to commit the .sparkrc file I created and now it is working.

Thanks.

rwaldron commented 9 years ago

But you should keep that line in your .bashrc (or similar)

Resseguie commented 9 years ago

@auch188 glad you got it working. As Rick said, if you put the source ~/.sparkrc (being sure it points to the correct location) in your .bashrc (or whatever shell you're using), then it will be loaded automatically for you in the future.

auch188 commented 9 years ago

Thanks for the info. Will do

On Sat, Nov 22, 2014 at 10:42 AM, David Resseguie notifications@github.com wrote:

@auch188 https://github.com/auch188 glad you got it working. As Rick said, if you put the source ~/.sparkrc (being sure it points to the correct location) in your .bashrc (or whatever shell you're using), then it will be loaded automatically for you in the future.

— Reply to this email directly or view it on GitHub https://github.com/rwaldron/spark-io/issues/42#issuecomment-64055629.