I'm trying to integrate github issues api into a project. I think I'm following the rules of oauth, and everything that is needed and mentioned on http://develop.github.com/p/issues.html, but it doesn't seem to work. I don't get detailed error message, just a 401.
- i registered an oauth app at github(api v2), and provided the callback url.
- i construct the auth url: https://github.com/login/oauth/authorize?client_id=...&redirect_uri=http://.../no_port/
- They post the code for me(request token), i exchange it ho access token, it works fine. The problems:
- I can watch my own issues on my own repos, but if i'm just a collaborator, it's 401(unauthorized)
- There's no way to create a new issue, even on my own repo: POST: http://github.com/api/v2/json/issues/open/:user/:repo PARAMS: body=&login=&token=6&title=
actual implementatios with django, python:
url = 'https://github.com/login/oauth/access_token?client_id=%(client_id)s&redirect_uri=%(redirect_uri)s&client_secret=%(client_secret)s&code=%(code)s' % locals()
req = urllib2.Request(url)
response = urllib2.urlopen(req).read()
access_token = re.search(r'access_token=(\w+)', response).group(1)
url = 'http://github.com/api/v2/json/issues/open/%(user)s/%(repo)s' % locals()
params = urllib.urlencode({'login': user, 'token': access_token, 'title': 'title', 'body': 'body'})
req = urllib2.Request(url, params)
try:
response = urllib2.urlopen(req)
except HTTPError, e:
return HttpResponse('[*] Its a fckin %d' % e.code)
except URLError, e:
return HttpResponse('[*] %s\n' % repr(e.reason))
else:
resp = json.loads(response.read())