const authOptions = { url: 'https://login.microsoftonline.com/common/oauth2/v2.0/token', method: 'POST', headers: { 'content-type': 'application/x-www-form-urlencoded' }, data: qs.stringify({ grant_type: 'refresh_token', client_id: clientId, client_secret: clientSecret, redirect_uri: redirectUri, refresh_token: refreshToken }) };

axios(authOptions) .then(response => { const accessToken = response.data.access_token; const refreshToken = response.data.refresh_token; console.log(Access token: ${accessToken}); console.log(Refresh token: ${refreshToken}); const newEvent = { subject: summary, start: start, end: end, location: { displayName: title } }; const options = { url: 'https://graph.microsoft.com/v1.0/me/events', headers: { Authorization: 'Bearer ' + accessToken }, data: newEvent }; return axios.post(options.url, options.data, { headers: options.headers }); }) .then(acquire => { console.log(acquire.data); }) .catch(error => { console.error(Failed to get access token: ${error}); });

Microsoft Graph API: Refresh Token and Event Creation with Axios

原文地址: https://www.cveoy.top/t/topic/mIVS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录