github issues api をプロジェクトに統合しようとしています。私は oauth のルールと、http://develop.github.com/p/issues.htmlで必要かつ言及されているすべてのものに従っていると思いますが、うまくいかないようです。詳細なエラー メッセージは表示されず、401 のみが表示されます。
- 私はgithub(api v2)でoauthアプリを登録し、コールバックURLを提供しました。
- 認証 URL を作成します: https://github.com/login/oauth/authorize?client_id=...&redirect_uri=http://.../no_port/
- 彼らは私のためにコードを投稿します(リクエストトークン)、私はそれをアクセストークンに交換します、それはうまくいきます。問題点:
- 自分の課題は自分のリポジトリで見ることができますが、単なる共同作業者の場合は 401(無許可) です
- 自分のレポであっても、新しい問題を作成する方法はありません: POST: http://github.com/api/v2/json/issues/open/:user/:repo PARAMS: body=&login=&token=6&title=
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())