.Net Maui Android app with Google login using WebAuthenticator doesn't work - xamarin.android

The Apple login works great in my iOS app. I've configured the server for Google, but can't get it to work. It's an Asp.net 6.0 Blazor WebAssembly API.
This line of code gets called in my Android app, but nothing is returned.
result = await WebAuthenticator.Default.AuthenticateAsync(authUrl, callbackUrl);
I configured the AuthController using this example.
https://github.com/dotnet/maui/blob/main/src/Essentials/samples/Sample.Server.WebAuthenticator/Controllers/MobileAuthController.cs
This line of code executes in my AuthController.
// Not authenticated, challenge
await Request.HttpContext.ChallengeAsync(scheme);
The Android app is targeting net6.0-Android31. The minimum target is net6.0-Android30. My test device is an Android emulator running API 31. I'm running Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.3.6 with Xamarin.Android.SDK version 13.0.0.0.
I also added this line in my MauiProgram.cs file.
builder.Services.AddSingleton(WebAuthenticator.Default);
Does anyone know how to get this to work? Thanks!

This line of code gets called in my Android app, but nothing is returned.
At first can you try to debug or get the response code of this request? In addition, how do you do the authentication? With a web browser or the webview in the android. It seems the webauthenticator can't be used with Google.
You can check this case which tried to use WebAuthenticator with Google. Furthermore, according to this issue on the github, you need to change the redirect url in the WebAuthenticator.Default.AuthenticateAsync(authUrl, callbackUrl);.

Related

Safari error on login Microsoft account with oauth2

I have a a problem on a Nativescript 5.1.0 project with Angular 4, I use the API nativescript-oauth2, and it works fine for Facebook and Google, but when I try to Login into Microsoft it does not do very well.
I can enter the e-mail account and password, even the permission screen is shown, but in this one when I press YES it crashes.
The problem is because of the property redirect uri (urn:ietf:wg:oauth:2.0:oob) for the Microsoft configuration, when Safari receives the redirect uri, Safari crashes.
I read that can be solved with a delegate, but it already exists in the nativescript-oauth2.
And the android browser does not show the error but it does nothing.
Help me please!!
With Microsoft oAuth, it tries to open your app with an URL scheme. You might want to setup URL schemes in your app like it's showcased in demo app for Provider, iOS & Android

ASP.NET MVC 5 (VS2013 final) external login from Android fails (loginInfo is null)

when I try to external login in my website using Android's default Browser as well as from Chrome Browser on Android - await AuthenticationManager.GetExternalLoginInfoAsync() always returns null.
I'm checking both Google and Facebook's authentication. For both I get the usual stuff asking me for my username and password and then I am returned to my website for completion and there I always get null for AuthenticationManager.GetExternalLoginInfoAsync().
The very same code works fine locally in debug.
Also, it used to worked fine up until two or three days earlier.
what might be the problem and hopefully the solution?
I have got same problem,and I found I forgot to enable my google Api+.
and make sure your website is host under https
go to see the Microsoft reference
official reference

The redirect_uri URL must be absolute error for deep linking URI fbAPP_ID://

Everything was working fine until today I've tried to test Safari Facebook login mechanism on my app and I started getting the following error on web browser:
The redirect_uri URL must be absolute.
I'm not using the Facebook SDK (for various reasons outside the question's context, so don't ask why) and I'm trying to open the following URL manually:
https://www.facebook.com/dialog/oauth?client_id=MY_APP_ID&response_type=token,granted_scopes&redirect_uri=fbMY_APP_ID://&scope=user_friends,user_birthday,email,user_photos&default_audience=friends&sdk=ios
Everything was working fine, until today where I realized that the URL isn't executing properly. I didn't change any app settings or anything. How can I complete my login flow? Yes, I need to redirect back to fbAPP_ID:// to launch my app back when using iOS versions lower than 9.0 where native Safari isn't supported. Or is there any known way of redirecting back to the application pre-iOS 9 from external Safari? (other than me redirecting to website, then on my website, redirecting back to my app by force opening fbAPP_ID:// from Javascript)
The only "redirect_uri" that works out of the box is fbAPP_ID://authorize , this is the one used by the Facebook SDK and anyone can use it as well.

Salesforce Native IOS SDK can't refresh access token

I am currently using the Salesforce.com IOS SDK Version 3.0 to build a native application that connects to salesforce. This app will be used for external users, so it is pointed at communities.
I first started by creating a Native IOS SDK app and getting that working and talking to salesforce.
I then created a new community, created a community user, gave them the proper permissions and finished setting up the community.
Next I went into the Xcode Project, under supporting files to the application plist. I then edited the SFDCOAuthLoginHost to be set to the community URL.
Once that was completed I restarted the app, and was able to login to the community through the native SDK and things would work great until the app hit its session timeout. At this point I receive these errors.
ERROR|SFNetworkOperation|callDelegateDidFailWithError Session expired or invalid
ERROR|SFNetworkOperation|Session timeout encountered. Requeue 0.000000or retry later
ERROR|SFNetworkEngine|Ignore session timeout error callback as host URL changed, request URL is https://dev-patientsupport-dev.cs21.force.com/dev/services/apexrest/patientNotifications, login host is [cs21.salesforce.com]
Of course because it cannot get a new session all web callouts fail after this point.
I have searched everywhere and cannot find a solution to this problem. My guess is that because the request is being made to the community URL, but the refreshed session is being sent from cs21.salesforce.com so it is being ignored. Thanks again for everyones time.
A fix for this bug has been submitted as part of Mobile SDK 3.1.1 patch on GitHub, npm (forceios), and Cocoapods. Please see https://plus.google.com/105428096535342044035/posts/AkoVwL5Kdt3 for more details.
It looks like this may be caused by the refresh token having its instanceURL set to the wrong destination when using communities. This may be a bug in the SDK as it works fine on the web. Try changing the instanceURL of the credentials to be the same as the URL of the community to see if that helps.

Cross-domain policy and XHR cookie for app development in Safari, Lion

I'm developing a web services application using various technologies such as :
Ruby on Rails on server side
Javascript, HTML5, objective-C, java on mobile side
I did not met any issue with developing the application until I updated my safari browser. I actually run :
Version 5.1.1 (7534.51.22)
I'm developing the mobile application using the Sencha Touch Framework. It works great when the js applicatin is wrapped by phonegap, but now, when I'm developing in safari with the protocole file://, my cookie are not saved.
Before I updated my safari version, the cookie was saved and correctly send to the server each time I made request.
To reproduce :
A. Opening the index.html file in a safari window :
file://~/project/myapp/index.html
B.XHR to the server with http: //localhost:3000/sign_in
C. You get the cookie and the correct success code from the server
D. You try to fetch other information using
http: //localhost:3000/users/1
you get : 401 Unauthorized.
Well, the server has not changed, only safari has been updated. What would be the correct way to do it.
And of course it works when I built the app for iOS, blackberry or Android.
Thank you !

Resources