Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
fix api auth
Browse files Browse the repository at this point in the history
  • Loading branch information
mike182uk committed Nov 19, 2020
1 parent 3cefc8a commit a272fa4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# 4.0.0

- Drop support for Node.js `< 10.0.0`
- Fix GitHub [API autentication deprecation](https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/)

# 3.0.0

Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ async function fetchGists (accessToken) {
const { body, headers } = await got('https://api.github.com/gists', {
headers: {
'User-Agent': 'fetch-gists',
accept: 'application/vnd.github.v3+json'
accept: 'application/vnd.github.v3+json',
Authorization: `token ${accessToken}`
},
searchParams: {
page,
per_page: 100,
access_token: accessToken
per_page: 100
},
responseType: 'json'
})
Expand Down
8 changes: 4 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ function mockGetGistsApiCall (page, body, isLastPage, statusCode = 200) {

const requestHeaders = {
'User-Agent': 'fetch-gists',
accept: 'application/vnd.github.v3+json'
accept: 'application/vnd.github.v3+json',
Authorization: `token ${ACCESS_TOKEN}`
}

nock('https://api.github.com', { reqheaders: requestHeaders })
.get('/gists')
.query({
page: page,
per_page: 100,
access_token: ACCESS_TOKEN
page,
per_page: 100
})
.reply(statusCode, body, responseHeaders)
}
Expand Down

0 comments on commit a272fa4

Please sign in to comment.