CSCI-4830-002-2014 / challenge-week-4

0 stars 14 forks source link

GitHub challenge 6 #7

Open dawsbot opened 10 years ago

dawsbot commented 10 years ago

Made it to the first POST in restler. I have been avoiding any parameters in the "options" category of [my restler object].get(url, options). Which is all fine and dandy if I hack up the URL with something like: "https://api.github.com/repos/CSCI-4830-002-2014/challenge-week-1/pulls?state=closed"

But now that I am on challenge 6 I believe this requires having a username in my POST request so that Github knows I have permissions to post an issue to a repo. Should I be using the "options" field of [restler object].post(url, options)?

Some skeleton to help with using options would be nice, Cheers

ghost commented 10 years ago

I'm having trouble with this too. This is the code I've been trying (it's based off the Restler documentation).

var rest = require('restler');

rest.postJson('https://api.github.com/repos/CSCI-4830-002-2014/challenge-week-4/issues', {
  multipart: true,
  username: '<my-username>',
  password: '<my-password>',
  data: {
    'title': '<title>',
    'body': '<body>'
  }
}).on('complete', function(data) {
  console.log(data);
});

I know it's close, but I can't seem to get it to work.

dawsbot commented 10 years ago

You have your Github password in these files in raw text? There must a different way, that can't be the assignment because of security issues.

Let's get some ideas in here from the teachers...Any help?

@wannabeCitizen

wannabeCitizen commented 10 years ago

So it is an authentication issue. You'll need to do some sort of authentication before you can POST data. Go to the authentication section here: https://developer.github.com/v3/ There are 3 different options, and you do not need to submit your authentication code with the solution.

Regarding password privacy. We would never ask you to submit something to us that has your password in it. However, putting your password in a script is no more/less safe than entering it on the website. If you do it over https, all your data should be encrypted with SHA-1 and be quite safe. For this assignment, you do not need to put any username/password in your request. OAuth will require you to create a session and get a token before you ever make your request.

dawsbot commented 10 years ago

Got it working @wannabeCitizen. Thanks for the direction. For reference: Yes, both data and options fields are both filled out with JSON formatted text.