Skip to content
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

Redirect URL #117

Open
erniukas86 opened this issue May 31, 2023 · 5 comments
Open

Redirect URL #117

erniukas86 opened this issue May 31, 2023 · 5 comments

Comments

@erniukas86
Copy link

How can I set this format to Google redirect URIs?
scheme://expo-development-client/?url=manifestUrl

image

Because. only HTTP and HTTPS allowed

@codingjam
Copy link

@erniukas86 did you find any workaround for it? I am following this migration doc auth-proxy-migration, but most of the OAuth providers do not allow non http/https urls to be set as redirectUri.

@Nikita-Shuminskiy
Copy link

is there a solution to the problem ? same problem, can't get redirected.

@JuliaNYC
Copy link

same issue

@JoniVR
Copy link

JoniVR commented Aug 13, 2024

@EvanBacon Is there a better solution to this issue yet? I saw you mentioned setting up your own proxy server and then redirect to the custom uri scheme, but that seems like a lot of work for something that could simply be done by using universal links.

The reason these providers are blocking uri schemes is simply because it's not safe and you can't verify that the app that is handling the uri scheme is the actual owner of the link.

I've tried using universal links as a solution to this, since these links require domain verification via apple-site-association/assetlinks, but this solution only works on Android, not on iOS for some reason. Do you have any idea why universal links do not work with expo-auth-session on iOS? The authentication seems to complete but the browser window isn't dismissed.

@JoniVR
Copy link

JoniVR commented Aug 16, 2024

For anyone running into this (only on iOS for me), I implemented a workaround. The problem seems to be that iOS doesn't dismiss the modal by itself when using a https link due to universal links not being handled internally, since iOS 17.4 Apple provided an api for universal link callbacks:
https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/callback/https(host:path:)

Not sure if this is an expo issue or just an iOS framework issue.

My custom workaround for now is to just attach a listener in case of ios and dismiss the modal myself when the link is called.

useEffect(() => {
    // In case of using a universal link for the callback, we need to listen to the url event and do stuff manually on ios...
    // See: https://github.com/expo/fyi/issues/117
    let listener: EmitterSubscription | undefined;
    if (
      Platform.OS === 'ios' &&
      !isNullOrEmpty(endpoint?.openIdConnect?.callbackOverride)
    ) {
      listener = Linking.addEventListener('url', event => {
        const { codeVerifier, redirectUri, clientId } = request!;
        const params = getUrlParams(event.url);
        const code = params.get('code');
        if (
          event.url?.startsWith(endpoint?.openIdConnect?.callbackOverride!) &&
          !isNullOrEmpty(codeVerifier) &&
          !isNullOrEmpty(redirectUri) &&
          !isNullOrEmpty(clientId) &&
          !isNullOrEmpty(code)
        ) {
          dismiss();
          authenticateWithOpenId(code, codeVerifier, redirectUri, clientId);
        }
      });
    }
    return () => {
      listener?.remove();
    };
  }, [request, endpoint?.openIdConnect?.callbackOverride]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants