2023-08-04 19:08:16 -04:00
|
|
|
import * as strava from './strava.js';
|
|
|
|
|
|
|
|
async function main() {
|
2023-08-31 12:31:24 -04:00
|
|
|
print('handler running');
|
2023-08-04 19:08:16 -04:00
|
|
|
let r = await strava.authorization_code(request.query.code);
|
|
|
|
print('state =', request.query.state);
|
|
|
|
print('body = ', r.body);
|
|
|
|
if (request.query.state && r.body) {
|
|
|
|
let shared_db = await shared_database('state');
|
2023-08-31 12:31:24 -04:00
|
|
|
await shared_db.set(request.query.state, utf8Decode(r.body));
|
2023-08-04 19:08:16 -04:00
|
|
|
}
|
|
|
|
await respond({
|
|
|
|
data: r.body,
|
|
|
|
content_type: 'text/plain',
|
|
|
|
headers: {
|
|
|
|
Location: 'https://tildefriends.net/~cory/gg/',
|
|
|
|
},
|
|
|
|
status_code: 307,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
main();
|