#john_70817
1 messages · Page 1 of 1 (latest)
Hi there, can you tell me more about the problems taht you are facing? what prevent from passing the data if you open a new tab?
I have a nodejs server message like the one in the sample: router.get("/oauth-link", async (req, res) => {
const state = uuidv4();
req.session.state = state;
req.session.authorization = req.headers.authorization;
console.log("/oauth-link: auth = %s", req.headers.authorization);
const redirectUrl = 'https://' + req.get('host') + '/onboard/authorize-oauth';
const args = new URLSearchParams({
state,
client_id: process.env.STRIPE_CLIENT_ID,
scope: "read_write",
response_type: "code",
redirect_uri: redirectUrl
})
const url = https://connect.stripe.com/oauth/authorize?${args.toString()};
console.log("Cookies = %s", JSON.stringify(req.cookies)); // remove later
return res.redirect(303, url);
});
And I open this in a new tab in my frontend: const oauthLinkURL = '<our_website>/onboard/oauth-link';
const headers = {
Authorization: Bearer ${tokenss},
};
const newWindow = window.open(oauthLinkURL, '_blank');
if (newWindow) {
newWindow.postMessage({ headers }, serverURL);
}
But the backend route (oauth-link) does not detect this header
So my hunch is that the header is not passed if i open a new tab
All of this code works for mobile, just having issue with web
I don't see a direct connection between using tab and not passing headers.
From what ive read, you can't pass headers when you open a new tab
Maybe I'm wrong
But I don't see the header get to the backend
So if there is any sample code that opens a new tab for the sample project (https://github.com/stripe-samples/connect-standard-oauth/tree/main), that could be helpful too
Here is what the sampel stripe project does:
fetch("/get-oauth-link", {
method: "GET",
headers: {
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => {
if (data.url) {
window.location = data.url;
This opens the url in the same page
I want it to open in a different tab
You can open a link in a tab if you set target=”_blank” attribute in the <a> tag
The sample stripe code doesn't have an <a> tag. it uses JS script to add a click listener to a div tag: https://github.com/stripe-samples/connect-standard-oauth/blob/main/client/script.js
ok, i was able to open a new tab using a different code:
fetch("https://mywebsite/onboard/oauth-link-return", {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + tokenss
}
})
.then(response => response.json())
.then(data => {
if (data.url) {
// Open the URL in a new window
const newWindow = window.open(data.url, "_blank");
if (newWindow) {
// Focus the new window (optional)
newWindow.focus();
}
}
});
I'm just checking if the entire flow works now, should I open a new message if i have issues with the flow after this?