Amplify-js: Auth.federatedSignIn() redirect url is null

Created on 7 Aug 2019  路  4Comments  路  Source: aws-amplify/amplify-js

* Which Category is your question related to? *
React-Native Auth - Federated

* What AWS Services are you utilizing? *
Cognito

* versions *
"aws-amplify": "1.1.35",
"react-native": "0.60.4",

* Provide additional details e.g. code snippets *

Amplify doesn't seem to be have access to the redirect url returned to the app after successful authentication (facebook or user pool). I would expect to see a url with an idToken & access_token returned and consumed by amplify. When I am redirected back to the app, I am not logged in. It looks to be something to do with the urlListener class in amplify. I can see that it tries to get the current url using Linking.getInitialURL() but this returns null.

This is somewhat related to an issue I raise a month or so back that didn't get resolved #3342

Thanks,
Chris

React Native question

Most helpful comment

Hey @manueliglesias my issue was that I was missing the below functionalists in my AppDeleagte.

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return RCTLinkingManager.application(application, open: url as URL, sourceApplication: sourceApplication, annotation: annotation)
    }

without this, RN was not able to pull the tokens off the incoming url.

Thanks for the help!

All 4 comments

I would expect to see a url with an idToken & access_token returned and consumed by amplify

Amplify does that automatically for you in the background (using React Native's AppState.addEventListener, see https://github.com/aws-amplify/amplify-js/blob/b7d2eb97ca4e6023da2253821cf2d26a90773bfb/packages/auth/src/urlListener.native.ts#L40)

This is a small sample app that i personally use to test these OAuth flows in react native https://github.com/manueliglesias/hosted-ui-react-native-cli maybe you find it useful or can try it yourself

Also, can you enable DEBUG logging in amplify and paste some logs without sensitive info?
https://aws-amplify.github.io/docs/js/logger

Amplify.Logger.LOG_LEVEL = 'DEBUG'

Hey @manueliglesias, Thanks for the quick reply. Yeah I get that amplify "should" handle all that. But it isn't. All the Auth functions like currentSession() currentAuthenticatedUser userSession() show that the user isn't logged in. I don't think amplify is pulling the tokens off the url for me. Im not even sure its getting access to the URL at all

@chriscraiclabs Do you see the same behavior with the sample app I linked? If so, is it very different from what you are currently doing in your app?

Hey @manueliglesias my issue was that I was missing the below functionalists in my AppDeleagte.

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return RCTLinkingManager.application(application, open: url as URL, sourceApplication: sourceApplication, annotation: annotation)
    }

without this, RN was not able to pull the tokens off the incoming url.

Thanks for the help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ldgarcia picture ldgarcia  路  3Comments

cosmosof picture cosmosof  路  3Comments

callmekatootie picture callmekatootie  路  3Comments

karlmosenbacher picture karlmosenbacher  路  3Comments

shinnapatthesix picture shinnapatthesix  路  3Comments