piece of data, the code, send this back to Slack along with the client_id and client_secret via your backend and not your frontend << very important. Whatever backend you use (Node.js, .NET, Java, Ruby, Python, Go) use the backend to submit a request with those URL params and return the resulting JSON response to the frontend. • While it’s possible, with some CORS sidesteps, to wire everything up via the frontend-only, it is highly not recommended, because you cannot hide your client_secret effectively on client side browser code — even using Webpack minify/ uglify, gzipping, Vue CLI, and other mangling techniques. slack.com/api/oauth.access? ?code=abc123 &client_id=<your_client_id>
&client_secret=<your_client_secret> Your App’s
Backend Slack slack.com/api/oauth.access // Login.vue
export default {
name: 'Login',
computed: {
code() { return this.$route.query.code; },
state() { return this.$route.query.state; },
},
created() { this.submitLogin(); },
methods: {
async submitLogin() {
const { data } =
await axios.post('http://api.mycoolapp.com',
{ code: this.code, state: this.state }
);
console.log(data); /* { "name": "John Tran",
"email": "
[email protected]",
"avatar": " ",
"access_token": "xyz789" } */
// Hooray! Now what? breakpoint
},
},
}; * Secrets are only truly secret on the server, not the browser Your App // backend.py import env, curl
@api_route('http://api.mycoolapp.com') def fetch_slack_oauth_data(request):
resp = curl.get(f’
https://slack.com/api/oauth.access
?code={request.params['code']}
&client_id={env.CLIENT_ID}
&client_secret={env.CLIENT_SECRET}
')
if resp.ok:
return Response(resp.json(), 200)
return Response(resp.reason, 500) Python Example