私はdjangoプロジェクトに取り組んでおり、ユーザー名とパスワードを使用してGithubログインを実装しようとしています.
私のviews.py
ファイルの内容は次のとおりです。
@login_required
def github_access_via_username(request):
if request.method == 'POST':
form = GitHubUserPassAuthForm(request.POST)
if form.is_valid():
username = form.cleaned_data.get('username')
password = form.cleaned_data.get('password')
payload = {
"scopes" : [
"repo", "admin:org", "admin:public_key", "admin:repo_hook", "admin:org_hook",
"gist", "notifications", "user", "delete_repo", "write:discussion", "admin:gpg_key",
],
"note" : "Permissions",
}
response = requests.post('https://api.github.com/authorizations', params=payload, auth=(username, password))
#json_response = response.json()
#access_token = json_response['token']
#user = Github(access_token)
return HttpResponse(response.status_code)
else:
form = GitHubUserPassAuthForm()
return render(request, 'core/github_login.html', {'form':form})
ここに出力がありますprint(reponse)
{'message': 'Problems parsing JSON', 'documentation_url': 'https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization'}
[23/Sep/2018 19:55:42] "POST /core/github_access_via_username/ HTTP/1.1" 200 5020
何も得られなかったので、 を返すことstatus_code
にしました400
。私は立ち往生しています。目を見張るものはありますか?