diff --git a/chapter-05/photo-share-api/lib.js b/chapter-05/photo-share-api/lib.js index ec52fc2..52dfca6 100644 --- a/chapter-05/photo-share-api/lib.js +++ b/chapter-05/photo-share-api/lib.js @@ -22,9 +22,15 @@ const requestGithubToken = credentials => ).then(res => res.json()) const requestGithubUserAccount = token => - fetch(`https://api.github.com/user?access_token=${token}`) - .then(res => res.json()) - + fetch( + 'https://api.github.com/user', + { + headers: { + Authorization: `token ${token}` + } + } + ).then(res => res.json()) + const authorizeWithGithub = async credentials => { const { access_token } = await requestGithubToken(credentials) const githubUser = await requestGithubUserAccount(access_token) diff --git a/chapter-06/photo-share-api/lib.js b/chapter-06/photo-share-api/lib.js index ec52fc2..52dfca6 100644 --- a/chapter-06/photo-share-api/lib.js +++ b/chapter-06/photo-share-api/lib.js @@ -22,9 +22,15 @@ const requestGithubToken = credentials => ).then(res => res.json()) const requestGithubUserAccount = token => - fetch(`https://api.github.com/user?access_token=${token}`) - .then(res => res.json()) - + fetch( + 'https://api.github.com/user', + { + headers: { + Authorization: `token ${token}` + } + } + ).then(res => res.json()) + const authorizeWithGithub = async credentials => { const { access_token } = await requestGithubToken(credentials) const githubUser = await requestGithubUserAccount(access_token) diff --git a/chapter-07/photo-share-api/lib.js b/chapter-07/photo-share-api/lib.js index ba8c272..cffe431 100644 --- a/chapter-07/photo-share-api/lib.js +++ b/chapter-07/photo-share-api/lib.js @@ -22,9 +22,15 @@ const requestGithubToken = credentials => ).then(res => res.json()) const requestGithubUserAccount = token => - fetch(`https://api.github.com/user?access_token=${token}`) - .then(res => res.json()) - + fetch( + 'https://api.github.com/user', + { + headers: { + Authorization: `token ${token}` + } + } + ).then(res => res.json()) + const authorizeWithGithub = async credentials => { const { access_token } = await requestGithubToken(credentials) const githubUser = await requestGithubUserAccount(access_token)