-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Social Authentication not working on Ionic #3537
Comments
Hi @oliverandersencox! The first issue to solve was to find a way to redirect URI into Ionic app after Facebook Login with the Browser. |
@giacomocarrozzo I gave up in the end! There has been no response from any of the devs on this issue so I thought I'd wait it out. I managed to get it working using the facebook and google ionic native packages - but as I said, that creates identities and not a cognito user which makes it pretty much useless! |
Yes, I'm trying to avoid the facebook and google native packages since I would like to fully manage users with AWS Cognito. Did you use Deeplinks to redirect URI to the App?
"match.$args" cointains Aws Cognito get params. |
@giacomocarrozzo yes I did the same with the redirect. Any word on this from the devs? |
No @oliverandersencox , I'm still waiting for an answer. I hope to get it soon otherwise I have to switch to another sign-up platform. |
Yea, I'm having the same issue. I don't see a way to use the hosted UI with ionic. It's become a huge blocker for me. |
Same here, blocked from using hosted ui with Ionic, However we need custom scopes. |
@amburt05 yes it is the same issue. I've been waiting on a fix for this for months now. It seems there a fix in a pull request but its hasnt been reviewed yet |
Any update on this? |
@haverchuck can we get some sort of feedback on this. Most apps built with Ionic need this feature, and it seems there has been no comment on any of the Social Auth threads for Ionic. |
@giacomocarrozzo have you had any luck here? I am going to try one approach today and hopefully get around this MASSIVE BLOCKER. |
Please post your solution if you figure it out @oliverandersencox . This is brick-walling my deployment, as well as everyone else' I'm sure. |
@oliverandersencox I didn't try to solve this issue anymore. If you take some step ahead and you would like to share it, I'll be happy to try to help you. |
Is there really zero feedback from the AWS team on this? We're trying to do some testing and are getting ready to just drop AWS cognito. This is kind of ridiculous. Do they just open source the stuff they just don't feel like dealing with? |
@oliverandersencox Apologize that we haven't replied on this issue. I did reference an open Pull Request (PR) for adding federated sign in for Ionic and Angular.. I am also seeing yourself comment on that Feature Request. We are following up with the person that cut the PR to see where it is at. I do want to know, can you provide the link to the documentation you are referring to? |
@sammartinez is there any info you can give us on this. The user is created in the user pool, the only issue is simply the redirect doesn't do any auth checks or pick up this new user and sign in. There must be some advice on manually detecting once redirected? |
@@giacomocarrozzo I finally got it working!! So the reason the authentication is not registered is because the Ionic webview is not loaded with the state and code from the redirect. These need to be passed to Ionic in order for Amplify to run its magic. In order to do so you need to add redirect URL's top the app and then intercept these deep links. In my case im using capacitor, which handles the deep links so I can grab the data:
From this point I now have the redirect query params passed back by Facebook and google. Now I need to load the application into the webview again but this time with the query params appended to it:
The next step is to ensure you have the amplify hub set up, as for some reason the auth state observable doesn't notice the event even after this.
At this point I have the facebook auth up and running. |
@oliverandersencox awesome! it's working to me too! I just have these errors when I log out after a Social Auth:
It that working for you? |
@giacomocarrozzo so I also had that. If you run it incognito mode, you wont get that issue. It seems cognito saves session data about the federated user, so that if you are removing and adding users in development it will throw this error. Try running in incognito the error should disappear. |
is there any update on this. It would be great if there was a way to manually pass the state and token to authenticate rather than having to reload the entire app, as this could be done with a browser pop over for a way better UX |
@shekhartupe Thank you for your quick response. I was doing all the steps you mentioned. However, it didn't work for me. There are a couple of issues that I solved to get it working.
And of course add the Amplfy Hub listener and act on different Auth events. |
I managed to get it working replacing capacitor:// with http://, looks like handleAuthResponse expects http or https. Here's my working code: import { Auth } from '@aws-amplify/auth' App.addListener('appUrlOpen', async (data) => { |
I cannot seem to call Auth._handleAuthResponse(url). It says the property is private. Is there a work around for this? |
I have the same problem. Do you have a fix or other way to make this works? |
Instead of Try like that :
That helps me a lot. |
Have you guys found an effective solution to address this issue? It appears that the solutions provided above may no longer be effective. I've been searching for methods to enable social authentication in Ionic for both Android and iOS platforms. Your insights on this matter would be greatly valued. |
Hi @marcangelx I currently use the latest version of amplify 5.3.10 and we are working without issues in production with web, android and ios. I had to do a few more tweaks to make it work, but it's very similar to my last comment. Here's how we make it work:
amplify oauth config
I hope it helps you |
Also important to have configured the url schema and deeplinks/universal link for android and ios. |
|
I'm a bit late, but it might help others. I was being redirected back to my app after trying to authenticate and when checking the logs it stopped at "set credentials from session". I'm using capacitor in the project and in my capacitor config file I had the CapacitorHTTP plugin enabled. After disabling the plugin it resolved the issue. Correct me if I'm wrong, but I think it has to do with CapacitorHTTP sending CORS-free requests and this isn't accepted by AWS. |
With AWS Amplify v6 and capacitor, Amplify Auth works for me. I'll share my implementation in case it is helpful to some.
|
Any solutions for v6 yet? I tried @alex-breen's solution but when I have universal links working with ios, the redirect from the hosted ui doesn't trigger the app opening, instead it opens in the safari browser, whereas if I click a link in a message or email it does open the app. Any solutions? |
I also have the issue of |
^ solved, just adding the But now I'm having an issue similar to @ryanweaver718. On first try, it works and redirects back to app authenticating! But if I try using sign in via google again, it breaks in subsequent times, it redirects to browser, and I ahve to manually copy redirect link to my notes app and click it for it to go to app. |
The docs tell us we can use federated sign in like so:
federatedSignIn('facebook')
To create a cognito user from facebook OAuth. However on a device with Ionic, the redirection process is broken.
In the browser, the process works great, however on IOS or Android it does not.
once the authentication is done, we cannot redirect back to localhost as it won't go back to the app.
If you set the redirect URI to the apps url schema, the redirection does work, however the authentication system does not pick this up when the app is opened from the login redirect.
I have in place a function that can detect the URL being used to open the app and it is correctly opening the app with the appended token information in the redirect URL.
However Amplify does not pick this up. I then tried implementing the HUB to detect auth changes and again this had no effect. Once the redirect away to the Amplify federated login page occurs, it effectively breaks the process.
It is possible to fix this by using the Facebook Ionic wrapper or the Google auth wrapper, however this creates a federated identity which then means you cannot read and write using the API.
Any advice on this would be great as this is a real blocker. Is there a way to take the redirect tokens and pass them to amplify manually? This would solve the problem.
The goal is to be able to create a cognito user in the Amplify pool, from the social providers.
The text was updated successfully, but these errors were encountered: