Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fhsinchy/bf0a855a645f1e743f19596f7dd4abce to your computer and use it in GitHub Desktop.
Save fhsinchy/bf0a855a645f1e743f19596f7dd4abce to your computer and use it in GitHub Desktop.
// src/views/OAuthCallbackHandler.vue
<script>
import axios from 'axios';
import { mutations } from '@/store';
export default {
async mounted() {
try {
const response = await axios.post('/oauth/token', {
grant_type: 'authorization_code',
client_id: process.env.VUE_APP_OAUTH_CLIENT_ID,
client_secret: process.env.VUE_APP_OAUTH_CLIENT_SECRET,
redirect_uri: process.env.VUE_APP_OAUTH_CLIENT_REDIRECT,
code: this.$route.query.code,
});
mutations.setToken(response.data.access_token);
window.localStorage.setItem('accessToken', response.data.access_token);
window.localStorage.setItem('refreshToken', response.data.refresh_token);
this.$router.push('/');
} catch (error) {
console.log(error);
this.$router.push('/');
}
},
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment