I have a React front-end, Firebase back-end trying complete the Stripe OAuth process. The redirect URI has come back (returning to https://mywebsitename.com/oauth_return) and the react component I have opening up on that page parses over that URL and accesses the Authentication Code and state. (please see below)
inside "oauth_return.js" file
import React from 'react';
import queryString from 'query-string';
const oauth_redirect = () => {
//Parsing over URL
const value=queryString.parse(window.location.search);
const code=value.code;
console.log('code:', code)
const state=value.state;
console.log('state:', state)
}
export default (oauth_redirect)
What I am having difficulty doing is trying to figure out how to make the firebase HTTP function return the authentication code via a POST method. All of my firebase functions exist inside the "index.js" file of the functions directory. All of the tutorials that I have seen show various ways of building this function in Typescript, but my code needs to be written in Javascript.
inside "functions/index.js" file
(...)
exports.stripeCreateOathResponseToken = functions.https.onRequest((req, res) => {
(...) Not sure what to write in this function to return the authorization code. All tutorials I've found are written in Typescript.
});
Unfortunately I don't understand how this HTTP function can be triggered to be called in the first place (i.e. do I need to explicitly call it inside the "oauth_return.js" file? How do I pass the authorization code into it? And most importantly, how does it send back the authorization code to Stripe?
Any clarity on this issue would be greatly appreciated.