Why do I get a null username when using Apple Sign In in my Flutter app? - flutter

I am trying to implement the Apple social login within my Flutter IOS App. I succeed to successfully connect, but in the credential received it seems there Is no personal information in it such as:
The username: which is null
The email: I only get the iCloud address, even when I select a personal email when signing in.
I am using firebase_auth: ^3.7.0
here is my code for connecting with apple:
signInWithApple() async {
final appleProvider = AppleAuthProvider()
..addScope("email")
..addScope("fullName");
try {
await _auth.signInWithProvider(appleProvider).then((credential) async {
print(credential.toString());
});
} on FirebaseAuthException catch (errorMessage) {
print(errorMessage);
}
}
I have also attached the credential I get from this code.
[![received credentials][1]][1]
[1]: https://i.stack.imgur.com/fBKXn.png
Do you have any idea of what is going wrong ?

Related

Login with facebook works on real phones but not emulators, it started happening with the new emulator update

This code works on real phones but not on emulators
I use flutter_facebook_auth. This exact code worked fine before emulator update and it's still works on real devices, but on emulator it just do nothing after coming back from fb login page.
static Future<User?> signInWithFacebook() async {
try {
//Trigger the sign-in flow
final LoginResult loginResult =
await FacebookAuth.instance.login(permissions: [
'public_profile',
'email',
'user_friends',
]);
if (loginResult.status == LoginStatus.success) {
print('success');
facebookAuthCredential =
FacebookAuthProvider.credential(loginResult.accessToken!.token);
print(loginResult.accessToken?.token);
Credential = await FirebaseAuth.instance
.signInWithCredential(facebookAuthCredential);
print('here 1');
UserData = await FacebookAuth.instance.getUserData(
fields:
"name,email,picture.width(400),birthday,friends,gender,link");
print(UserData);
} else {
print(loginResult.message);
error = loginResult.message!;
}
user = Credential.user;
await user
?.updatePhotoURL(UserData['picture']['data']['url'])
.then((value) {
print('success' + UserData['picture']['data']['url']);
});
return Credential.user;
} on FirebaseException catch (e) {
error = e.code;
print(e.code);
}
}
}
In the above code the app flow stops or freezes on
Credential = await FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);
What I have tried is:
Tried other emulators, different api's and models.
I tried adding new release and debug keyhashes to both facebook and firebase
I tried increasing emulator ram and cpu cores etc
I tried refreshing fb sdk and json and other dev dependencies
I tried flutter clean
I tried Invalidate Caches
I uninstalled android studio and all of it's components and install again
Is this happening with just me or it's a bug in the new emulator update?
It's been 12 hours, can somebody please help and check if their updated emulator is working with fb login
I solved it by downgrading emulator version to 31.2.9,
Here is emulator_archive how you can do it:

Calendar clientViaUserConsent it gives me Authorization Error while creating event

clientViaUserConsent opens URL in browser but it said invalid request. this URL is generated internally from lib. I had double-checked my ClientId for both platforms but still face issues for getting AuthClient for create a calendar event.
I used the below packages to create events in the google calender.
googleapis: ^8.1.0
googleapis_auth: ^1.3.0
static final androidClientId = ClientId('xxxxxxxx.apps.googleusercontent.com');
static final iOSClientId = ClientId('xxxxxxx.apps.googleusercontent.com');
final _clientID = Platform.isAndroid ? EventProvider.androidClientId : EventProvider.iOSClientId;
final _scopes = [CalendarApi.calendarScope];
clientViaUserConsent(_clientID, _scopes, prompt).then((AuthClient client) {
var calendar = CalendarApi(client);
}
void prompt(String url) async {
print(" => $url");
if (await canLaunch(url)) {
await launch(URL);
} else {
throw 'Could not launch $url';
}
}
I am referring to this article for creating an event in google calendar.
https://blog.codemagic.io/google-meet-events-in-flutter/
https://medium.com/flutter-community/flutter-use-google-calendar-api-adding-the-events-to-calendar-3d8fcb008493
You are seeing that error because the app hasn't been verified. If you are the app developer I advise you to check the App Verification FAQ to learn more about the verification steps. If you aren't the developer, you could try to enable the less secure app access but please be mindful of the consequences:
Less secure apps can make it easier for hackers to get in to your account, so blocking sign-ins from these apps helps keep your account safe.

Open an app in flutter based on the url provided in the email sent for verification

So I have been working on a flutter app and once the user registers through my app they are sent an email for the verification of their account. Once the url in the link is tapped they are verified. Now after their verification,the users must be redirected to the app. I looked into firebase dynamic links but in all of the articles,they were trying to share their app by generating a link. Is there a way I can implement this? Thanks in advance!
Use this package
https://pub.dev/packages/uni_links
For getting the link when the app is started.
This is the case in which your app was in the closed state.
Future<Null> initUniLinks() async {
// Platform messages may fail, so we use a try/catch PlatformException.
try {
String initialLink = await getInitialLink();
// Parse the link and warn the user, if it is not correct,
// but keep in mind it could be `null`.
} on PlatformException {
// Handle exception by warning the user their action did not succeed
// return?
}
}
For listening to link clicks. This is for the case when your app is already open and you click the link.
_sub = getLinksStream().listen((String link) {
// Parse the link and warn the user, if it is not correct
}, onError: (err) {
// Handle exception by warning the user their action did not succeed
});
// NOTE: Don't forget to call _sub.cancel() in dispose()
}
Usually, you need to implement both of them together since your app may be in the closed state or open state while you click the link.
Future<Null> initUniLinks() async {
try {
String initialLink = await getInitialLink();
} on PlatformException {
}
_sub = getLinksStream().listen((String link) {}, onError: (err) {});
}}

How to use Steam (OpenId) to login into my Firebase powered Flutter app?

I'm building a Flutter app and I want users to be able to login through Steam (OpenId).
The app is powered by Firebase.
I'm pretty new to the whole OpenId world and I've read into it but I'm still not getting it.
I found that Firebase Supports signinWithCustomToken so I think I should get the Steam OpenId to get me one of those.
I also found two packages which might help me but I couldn't get those to work either:
https://pub.dev/packages/openid_client
https://pub.dev/packages/steam_login
If tried the following sample from the openid_client package:
_authenticate(Uri uri, String clientId, List<String> scopes) async {
try {
var issuer = await Issuer.discover(uri);
var client = Client(issuer, clientId);
print('CLAIMS:');
print(issuer.claimsMap);
urlLauncher(String url) async {
if (await canLaunch(url)) {
await launch(url, forceWebView: true);
} else {
throw 'Could not launch $url';
}
}
var authenticator = Authenticator(client,
scopes: scopes, port: 4000, urlLancher: urlLauncher);
var c = await authenticator.authorize();
closeWebView();
print(await c.getUserInfo());
}catch (err) {
print(err);
}
}
But I have no idea what to give as the uri, clientId and scopes.
For the uri I've tried https://steamcommunity.com/openid but when I try this I'm getting an error that it tried to Json.parse a xml response.
I've also tried the example for the steam_login package here, but that does nothing and doesn't feel like it should work within a Flutter app (even though the package states it Flutter compatible).
So if anybody could explain to me how I could achieve this with a working sample that would be great.
If I get this to work I'm planning on creating a tutorial/guide for it for others.

FIrebase Google auth operation not supported in this environment

I am working on ionic and firebase project, made a login page to sign in with google. I am using this Below.
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithRedirect(provider).then(function (result) {
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
$state.go('app.homepage');
}).catch(function (error) {
});
firebase.auth().getRedirectResult().then(function (result) {
if (result.credential) {
var token = result.credential.accessToken;
}
// The signed-in user info.
var user = result.user;
}).catch(function (error) {
});
When I run it in the browser it is working fine, but when I run it in android device I am getting auth/operation-not-supported-in-this environment.
The application is running on "location.protocol".
I researched a bit but could not find an exact answer. What could be wrong ?
popup and redirect operations are not currently supported in Ionic/Cordova environment. As a a fallback you can you an oauth cordova plugin to obtain a google/facebook OAuth access token and then sign in the user via signInWithCredential. Check this thread for more on this:
auth.signInWithCredential(firebase.auth.FacebookAuthProvider.credential(fbAccessToken));
https://groups.google.com/forum/#!searchin/firebase-talk/facebook$20cordova/firebase-talk/mC_MlLNCWnI/DqN_8AuCBQAJ
Try the following because local storage is not enabled in webView, which is required for firebase
webSettings.setDomStorageEnabled(true);