GitHubのAPIでこれを行う場合は、リクエストを変更する必要があります。
まず、あなたはそうのような/authorizations
endpointを使用する必要があります
POST /authorizations
Authorization: Basic ...
Content-Type: application/json
Content-Length: ...
{
"scopes": [
"repo",
"write:org"
],
"note": "Example from StackOverflow by @sigmavirus24",
"client_id": "Your client_id here",
"client_secret": "Your client_secret here",
"fingerprint": "1234",
}
これは、そのようにのような体を持つ201 Created
応答を返す必要があります:それは本当だろう除き
{
"id": 72249124,
"url": "https://api.github.com/authorizations/72249124",
"scopes": [
"repo",
"write:org"
],
"token": "abcdefgh12345678",
"token_last_eight": "12345678",
"hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8",
"app": {
"url": "http://my-github-app.com",
"name": "my github app",
"client_id": "abcde12345fghij67890"
},
"note": "optional note",
"note_url": "http://optional/note/url",
"updated_at": "2017-02-08T20:39:23Z",
"created_at": "2017-02-08T17:26:27Z",
"fingerprint": "1234"
}
を。
つまり、GitHubを認証プロバイダとして使用できるエンドポイントを使用しようとしているようです。言い換えれば、ユーザーがGitHubでサインインできるアプリケーションを構築しています。その場合は、具体的にはWeb Application Flow for OAuthに従う必要があります。
この場合、あなたはその方法の一部ですが、間違ったパラメータを送信しています。
まずあなたがGETリクエストを行います。そして、あなたはその後、あなたのPOST
POST https://github.com/login/oauth/access_token?client_id=<your-client_id>&client_secret=<your-client_secret>&code=<code-from-github>
Accept: application/json
に使用する必要がありますバックのGitHubからのデータを受信します
GET https://github.com/login/oauth/authorize?client_id=<your-client_id>&scopes=repo%20write:org&state=something-random
、あなたが作るすべての要求は
を持っている必要があります
Authorization: token <token-received-in-response-to-POST>
乾杯!
あなたの質問は非常に曖昧です。私は私の答えに2つの可能な解決策を掲示しました。それらが正しくない場合は、あなたの質問を更新する必要があります。詳細が少なすぎるためです。 –
ローマ、私の答えを見て、他に質問があればお知らせください。 –