forked from kaimallea/node-imgur
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(src): now supports the use of a refresh token to obtain an access…
… token this update also removes all references to the use of a username and password, which is an authentication method no longer available from the imgur API.
- Loading branch information
Showing
9 changed files
with
64 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
const { ImgurClient } = require('../dist/imgur.node'); | ||
const { ImgurClient, getAuthorizationHeader } = require('../dist/imgur.node'); | ||
const { createReadStream } = require('fs'); | ||
const { join } = require('path'); | ||
require('dotenv').config(); | ||
|
||
const album = process.env.ALBUM; | ||
const imgur = new ImgurClient({ | ||
username: process.env.USERNAME, | ||
password: process.env.PASSWORD, | ||
refreshToken: process.env.REFRESH_TOKEN, | ||
accessToken: process.env.ACCESS_TOKEN, | ||
clientSecret: process.env.CLIENT_SECRET, | ||
clientId: process.env.CLIENT_ID, | ||
}); | ||
|
||
const imageStream = createReadStream(join(__dirname, 'small.jpg')); | ||
const videoStream = createReadStream(join(__dirname, 'small.mp4')); | ||
const run = async (client) => { | ||
|
||
imgur.upload({ album, image: imageStream, type: 'stream' }).then(console.log); | ||
imgur.upload({ album, image: videoStream, type: 'stream' }).then(console.log); | ||
await getAuthorizationHeader(client).then(console.log) | ||
|
||
const imageStream = createReadStream(join(__dirname, 'small.jpg')); | ||
const videoStream = createReadStream(join(__dirname, 'small.mp4')); | ||
|
||
await client.upload({ album, image: imageStream, type: 'stream' }).then(console.log); | ||
await client.upload({ album, image: videoStream, type: 'stream' }).then(console.log); | ||
|
||
} | ||
|
||
run(imgur) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { ImgurClient } from './client'; | ||
export { ImgurClient, ImgurCredentials, ImgurApiResponse } from './client'; | ||
export { getAuthorizationHeader } from './getAuthorizationHeader' | ||
export default ImgurClient; |