oh-my-posh/docs/api/auth/index.js

22 lines
719 B
JavaScript
Raw Normal View History

2022-01-04 00:39:45 -08:00
const axios = require('axios').default;
2022-01-03 08:38:07 -08:00
module.exports = async function (context, req) {
2022-01-04 00:39:45 -08:00
context.log('JavaScript HTTP trigger function processed a request.');
// http://www.strava.com/oauth/authorize?client_id=76033&response_type=code&redirect_uri=https://ohmyposh.dev/api/auth&approval_prompt=force&scope=read
const code = (req.query.code || (req.body && req.body.code));
2022-01-03 08:38:07 -08:00
2022-01-04 00:39:45 -08:00
var data = {
client_id: process.env.STRAVA_CLIENT_ID,
client_secret: process.env.STRAVA_CLIENT_SECRET,
code: code,
grant_type: 'authorization_code',
};
const resp = await axios.post('https://www.strava.com/oauth/token', data);
2022-01-03 08:38:07 -08:00
2022-01-04 00:39:45 -08:00
context.res = {
// status: 200, /* Defaults to 200 */
body: resp.data
};
2022-01-03 08:38:07 -08:00
}