The next time you need to do something like this, take a look at https://github.com/openid/AppAuth-JS.
Here is an example which uses Node, and obtains your access tokens. (https://github.com/openid/AppAuth-JS/blob/master/src/node_ap...)
Once you have that - you can make any API requests by using the correct Authorization headers.