Hi guys , i’m trying to implement stripe connect authflow using fuse webview , everything is working great except that i’m struggling to understand how can i get the success response from the webview.
i chose to put all the necessary code to perform the auth in my nodejs server , this is what its looks like
app.get('/authorize', function(req, res) {
// Redirect to Stripe /oauth/authorize endpoint
res.redirect(process.env.AUTHORIZE_URI + '?' + qs.stringify({
response_type: 'code',
scope: 'read_write',
client_id: process.env.CLIENT_ID
}));
});
app.get('/oauth/callback', function(req, res) {
var code = req.query.code;
// Make /oauth/token endpoint POST request
request.post({
url: process.env.TOKEN_URI,
form: {
grant_type: 'authorization_code',
client_id: process.env.CLIENT_ID,
code: code,
client_secret: process.env.StripeKey
}
}, function(err, r, body) {
var stripe_user_id = JSON.parse(body).stripe_user_id;
// Do something with your accessToken
// For demo's sake, output in response:
res.send({ 'Your_Token': stripe_user_id });
});
});
in fuse i’m just calling the url authorization to be redirected to stripe auth page
function connectToStripe(){
WhileTrueSet.value = true;
url.value = "https://URL/authorize";
}
<Panel ux:Name="NotRegistratedInStripe">
<WhileTrue Value="{WhileTrueSet}">
<NativeViewHost ux:Name="nvh" Background="#ddd">
<Panel ux:Name="loadingIndicator" Opacity="0" Alignment="Bottom" Color="#0006">
<Text Alignment="Center" Margin="10" Color="#fff">Loading...</Text>
</Panel>
<WebView ux:Name="webView" Url="{url}">
<PageLoaded>
<EvaluateJS Handler="{pageLoaded}">
return { url : document.location.href };
</EvaluateJS>
</PageLoaded>
<WhilePageLoading>
<Change loadingIndicator.Opacity="1" Duration="0.2" />
</WhilePageLoading>
</WebView>
<AddingAnimation>
<Change nvh.Opacity="0" Duration="0.3" />
</AddingAnimation>
</NativeViewHost>
</WhileTrue>
</Panel>
My question is how can i get from the webview the response sended ? do i need to do the work done in my server directly in fuse? can anyone help me understand