1const axios = require('axios');
2const oauth = require('axios-oauth-client');
3const getAuthorizationCode = oauth.client(axios.create(), {
4 url: 'https://oauth.com/2.0/token',
5 grant_type: 'authorization_code',
6 client_id: 'foo',
7 client_secret: 'bar',
8 redirect_uri: '...',
9 code: '...',
10 scope: 'baz',
11});
12
13const auth = await getAuthorizationCode(); // => { "access_token": "...", "expires_in": 900, ... }