Paypal refused to connect from Flutter web - flutter

I'm Loading the web URL inside the webview, all URL is working fine. But when I try to load the Paypal screen that time getting a problem. PayPal screen successfully loading when I try from the mobile device. But when I try to load the same screen from a web Browser it's shows Paypal refused to connect. I'm doing web development using flutter. Other web site loading fine. only got the issue in Paypal.
Below url i'm trying to laoding
https://www.paypal.com/connect//flowEntry=static&client_id=AYcri***********&redirect_uri=${_redirectUrl}&scope(0)=email&scope(1)=openid&response_type=code#
below is the sample that works on mobile but does not work in the web browser
WebView(
javascriptMode: web.JavascriptMode.unrestricted,
navigationDelegate: (web.NavigationRequest request) {
// This can intercept any navigation within the WebView.
if (request.url.startsWith(_redirectUrl)) {
// final startIndex = request.url.indexOf('code=');
String tokenPath = request.url.split("code=")[1];
if (tokenPath.contains("&scope=")) {
token = tokenPath.split("&scope=")[0];
}else{
token = tokenPath;
}
print(token);
Get.back(result: token);
return web.NavigationDecision.prevent;
}
return web.NavigationDecision.navigate;
},
onWebViewCreated: (web.WebViewController webViewController) {
webViewController = webViewController;
webViewController.loadUrl("https://www.paypal.com/connect//flowEntry=static&client_id=AYcri***********&redirect_uri=${_redirectUrl}&scope(0)=email&scope(1)=openid&response_type=code#",);
},
);
N.B I know the Web view library is not supported for Web, I used an extra plugin that helps to support the web.
How can I solve this issue? any suggestion?

PayPal does not support webviews; they should not be used for either mobile or web.
Instead, for mobile: "launch the PayPal web page within the system browser or an approved browser-view mechanism such as Safari View Controller on iOS or Chrome Custom Tabs on Android."
(Once you have code that opens a Safari View Controller / Chrome Custom Tab that works on mobile, it's possible there exists some plugin that will emulate and open a new browser tab when the same flutter code is run from web but I can't speak to that)

Related

Access Blocked: authorisation error. flutter

I just released my first app and It has a button in it that takes you to a website.
A user just sent me this:.
I tried googling Google's secure browsers policy but not much info is coming up.
how can I make my app comply with this policy? I think the button opens a browser in app (I use duckduckgo as my default browser and haven't had an issue)
is it just a case of opening a browser and then heading to the website when the button is pressed?
my code to open the website is:
_launchURL() async {
const url = 'https://www.thiswebsite.com';
final uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri);
} else {
throw 'Could not launch $url';
}
}
thanks so much and any help would be greatly appreciated
Google is trying to make sure, you open this window in an actual new browser window, not in a webview still under the control of your application.
Your code should open an external browser.
Maybe the user has no browser installed on their device? Maybe their default browser is some exotic thing not recognized by Google?
If you are using the latest version of url_launcher (currently 6.1.8) there is not a lot more you can do.
You could force the app to take the external browser, not the in-app webview:
await launchUrl(_url,mode: LaunchMode.externalApplication);
But that should be what happens anyway. If your version is up to date, ask your user, what browser they use. Be prepared to tell them that they need to use another one.

Problem with Webview showing Google Photos in Flutter

I am using flutter_webview_plugin: ^0.3.11
This is my code
Widget build(BuildContext context){
return WebviewScaffold(
url: glbPhotoURL,
withJavascript: true,
scrollBar : true,
withZoom: true
)
url: glbPhotoURL => here glbPhotoURL is a URL that I am passing
When I am using any normal URL it is running fine (like http://www.google.com, http://youtube.com"
Even url like - https://youtu.be/o5UPfG1eIw4 is running fine
But when I am using any google photo url (short url) it is throwing an error net::ERR_UNKNOWN_URL_SCHEME for eg - https://photos.app.goo.gl/FkQenAD8kQQc4TSr6
If I am using the expanded URL it shows the pictures -https://photos.google.com/share/AF1QipNItZG3Cg_hn9__2QnuVh3nNMbRuGxQaQSWZ76qni7L7h0ORbauolcH3AKe0MOnEA?
key=emc1Mk1CenRJRjloMjV5V1AzcmczNUprcGFsbmR3
Please help me resolve the issue
As of now I am running it on Android physical device.
Google Photos uses Firebase Dynamic Links. I suggest launching the link externally. I encountered a similar error on Android before, when Firebase Dynamic Links are being forced to be loaded in a WebView. FDLs are expected to be handled by Google Play Services in Android. But since the WebView doesn't know what to do with the link it's forced to display, the WebView returns "net::ERR_UNKNOWN_URL_SCHEME" error.
Open the link externally by using url_launcher. Use RegEx to filter intent URLs and check if the URL can be launched and be handled externally (outside the app).
var yourURL = "URL goes here";
// Check if URL contains Google Photos URL
yourURL.contains(RegExp('^https://photos\.app\.goo\.gl/.*$')){
// Check if the URL can be launched
if (await canLaunch(yourURL)) {
await launch(yourURL);
} else {
print('Could not launch $yourURL');
}
}

Firebase Polymer PWA with custom domain, signInWithPopup doesn't work on mobile device

Testing on desktop works fine, the various provider's popups come up. On mobile device however with each provider a new browser window opens, but the address is the non-customized hosting URL of the firebase app and the sign-in flow halts.
Originally the Firebase documentation advises the non custom hosting URL to be used in the redirect URLs. I changed those for all providers to the custom one: https://valleydevfest.com/__/auth/handler instead of https://valleydevfest-620d6.firebaseapp.com/__/auth/handler (for both Facebook app, Twitter app and my Github app too). That didn't help at all and the mobile Chrome still redirects to some https://valleydevfest-620d6.firebaseapp.com/... address, which either halts loading or it loads a very broken version of the website (instead of the OAuth login).
Most relevant code:
var signIn = function(providerId) {
var provider = getProviderForProviderId(providerId);
var that = this;
return this.auth.signInWithPopup(provider).catch(function(error) {
...
https://github.com/gdgfresno/valleydevfest/blob/develop/scripts/helper/firebase.js#L43
How can I overcome that?
(Whole source of the app: https://github.com/gdgfresno/valleydevfest/tree/develop)

Worklight saml 2.0 SSO

I am using Worklight 6.0 and in this case testing with iOS7.
I'm trying to setup saml 2.0 SSO with Worklight and I seem to have succeeded, but I don't know how it works... At first, I have my app attempt to access my url like this:
WLJQ.ajax({
url: 'url.com',
type: 'GET',
xhrFields: {
withCredentials: true
},
success: function(data, status, xhr) {
console.log(data);
},
error: function(result) {
console.log("error");
console.log(result);
}
});
The request goes to success and returns me the url of the login page, which is correct because I haven't authenticated yet, but it does not display the login (as I intended).
Next I click a button to display a Native page (iOS) which is a UIWebView of url.com. This displays the login page via:
WL.NativePage.show('LoginController', backFromNativeLoginPage, params);
I log in successfully and see the contents of url.com that I expect. Then I return back to the non-native app via:
[NativePage showWebView:0];
Now that I'm back in the non-native code, I sent the same request above and I expect for it not to return the contents of url.com, but rather the login page because I have no headers attached to my request and I think the non-native code shouldn't have any knowledge of the cookies I may have made in the UIWebView.
My question is how does this work? Does my non-native part of worklight have knowledge of all the cookies that were created in the native code's UIWebView?
Let me start by saying my answer is partly based on speculation, but I think this is whats happening:
Since your Native page is using the a WebView and Cordova is also using the WebView, any headers and cookies that your Native page is using will be visible when you return from native since cookies are shared across differet UIWebViews.
If your native page was using the native URL request methods or some third party / open source mechanism for connecting to your backend server, then I would think that your non-native page would not be able to see the headers and cookies.

Ajax call to check if native iPhone application exists on the device?

For our iPhone native application we have a URL : example://
On the iPhone if I type this URL (example://) in safari it automatically opens up my application.
From my "regular" website I have a link which when the user clicks it opens the application. The problem is that if the application is not installed on the iPhone it throws "Unable to open" error.
So before rendering the link on my "regular" site I need to check if the app is installed, one solution is to make an Ajax call and check for status code:
$.ajax({
type: 'POST',
url: 'example://',
complete: function (transport) {
if (transport.status == 200) {
alert('Success');
} else {
alert(transport.status);
alert('Failed');
}
}
});
But this code is always returning a status code "0".
Is there a way to find out from the web if the native iPhone app is installed?
If u are referring to Mobile Safari, you're out of luck. There's no documented public API that I know of that can do this. Mobile Safari is sandboxed away from the OS.
If it's in a webview within an app, u can request the URL and let the webview delegate talk to the native app / query the handling of example://. Otherwise, no way the browser can know existence of any installed app.