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 sign in with Apple fail to generate the correct url to apple sign in #13351
Comments
hello @mpark1 . Apologies for any inconvenience using the library. Could you please share your amplify configuration ? Please refrain from adding any sensitive values. Can you also manually configure Amplify and see if you are getting the same issue ? |
@israx @cwomack I’ll follow up with the amplify configuration and the Auth flow and the code in couple hours. In the meantime, I want to clarify how signinwithredirect should work. Currently, I’m using Cognito for user sign up. My understanding was that when a user who hasn’t signed up on app should be able to click on ‘sign in with apple’ button which then should show the the apple sign in page -> user signs in and we get back the information about this apple account -> then that somehow signs up the user at the same time and automatically creates a user in my Cognito user pool. Is there some loophole in my understanding of how signinwithredirect works? I ask because I’m thinking maybe the user needs to sign up first through regular email and password option with Cognito, only then they should be able to sign in with idp. |
@israx Could you clarify what is meant by manually configuring Amplify? Do you mean using Amplify CLI? Here's what I've attempted thus far:
I've run amplify push/pull every time I was updating the configuration with CLI. Below is my cli-inputs.json
When calling signInWithRedirect, the browser tries to open ap-northeast-2.amazoncognito.com which obviously doesn't exist on the server. I would have expected something like hostedUIDomainName.auth to be prepended but is missing in the url that should take me to the apple sign in page. Attaching simulator screenshot for reference: Update: Strangely, when running on emulator, I see that the redirect url is https://milkyway I was browsing through Amazon Cognito User pools App Integration where we can set up a domain, but regardless of setting the cognito domain or the custom domain there, I would be forced to use the hosted ui instead of my own sign in/sign up ui, right? I'm clueless at this point what could have gone wrong in the configuration. |
@cwomack I have a fairly simple Auth flow. I've included the SignIn page's code but bascially it's the first screen when my app launches when no user is signed in. And to summarize what SignIn screen contains, it just have the sign in with apple button which opens the webview when pressed and I would have expected it take me to the Apple's sign-in page. Right now, I am able to get the webview to open on my simulator but it never reaches the Apple's sign-in page and I don't get any console logs. The webview just displays a message that it doesn't exist on the server because the url it gets is "ap-northeast-2.amazoncognito.come" so no information about my app's domain is included. Also I don't get any console log when the webview opens, but when I close it, I get "res from Apple sign in: undefined". It should be clear from this code that I'm implementing my own ui for signin/signup and we're not wrapping our app with hosted ui for authentication provided by amplify. For instance, I've seen examples that uses As far as I could gather from the official doc, using the Authenticator from @aws-amplify/ui-react-native shouldn't be necessary to implement social sign-in. Is this correct? Index:
App.tsx:
SignIn code:
|
@israx Here's my latest amplifyconfiguration.json:
|
Hello @mpark1 . Thank you for all the context. To answer a couple of your questions.
You don't have to use
Yeah in addition to configure Amplify using the CLI. You can pass your configuration as follows
|
Based on your dependencies I think you need to include the |
@israx I do have @aws-amplify/rtn-web-browser in my project's root package.json which I didn't share here, but is there any other place that this dep should be included? I'm not sure if you meant this as the @aws-amplify/rtn-web-browser has to be included in the 'amplify' directory of my react native project. |
The dep should be included in your root project, no in the |
@israx Sure! Here's my root project package.json
I double checked the federated sign in provider (apple) settings from the AWS Cognito console matched with what I have on my Apple Developer's page (like team ID, service ID, etc). I tried testing sign in with apple on my iPhone as well as the simulator and it turns out it was grabbing the "expected" redirect url from signinwithredirect, yet even when testing on the actual device, I'm still getting the "server cannot be found error" with the @aws-amplify/rtn-web-browser dep there. The behavior is the same on android. Looking at the source code for signinwithredirect and comparing it to the url returned from the api call,
I assumed this is the correct url. (FYI, the client_id param matched with my amplify web client id). At this point, I'm clueless as to what could have gone wrong on my end when I was setting things up. I thought maybe the Apple private key uploaded to Cognito was incorrect/corrupted so I reuploaded that, but the key isn't even necessary during the step where the user should first be taken to the apple's sign in page when the url returned from signinwithredirect is provided. Please advise. |
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
Amplify CLI
Environment information
Describe the bug
I am trying to implement sign in with apple functionality in my react native app. I've followed the instructions under the official doc's "Add social provider sign-in" section.
I believe to have configured everything as instructed in the doc on 1. Apple developers site and 2. From Amplify CLI through amplify update auth.
The code block shown is how I'm calling signInWithRedirect. I'll add that I'm not using the Hosted UI for sign in/sign up and have our own implementation of the sign in ui. We simply have a button that calls signInWithRedirect when pressed.
Now the issue we have is that when signInWithRedirect is called, the url it tries to open in the rtn-web-browser is invalid. For instance, I noticed that one of the aws config related files, we have 'hostedUI:true', and 'hostedUIdomain: appname....-dev.auth.location.com', so I'd expect that signInWithRedirect should receive a url that is "appname....-dev.auth.location.com", yet in our app, we keep getting just "location.com" i.e. something along this line but without the "appname..-dev.auth" prepended in front.
Is this because my app is not using the hosted ui for sign in? If that's the case, how are we supposed to implement sign in with apple? Lastly, I should point out that completing steps 1 and 2 didn't work so I ended up doing the same configuration from AWS Cognito console as well as within Amplify studio's Authentication tab and this seems to have caused some misalignment in the sign up password requirement, but regardless, there's definitely something wrong going on with the url that should prompt navigation to the apple sign in page.
Expected behavior
signInWithRedirect with provider Apple should generate a url that matches with the hosted ui domain which in turn will prompt navigation to the apple sign in page when everything is set up right.
Reproduction steps
Code Snippet
// Put your code below this line.
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: