Back

Flutter + Magic Link Auth: Missing redirect URL

  • 1
  • Android
  • Flutter
  • Apple
Elena (@elukashova)
5 May, 2024, 08:47

Hello, I'm trying to implement Magic Link Auth on a Flutter App, and I have two fundamental questions:

  1. How can I test the magic link on Android Emulator (I don't have a physical Android device)? The link is being sent to the email, but then I have the screen "Missing redirect URL". I've implemented deep linking and routing (will send the routing in the next message otherwise I exceed the 2000 chars limit):
TypeScript
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<intent-filter>
  <action android:name="android.intent.action.MAIN"/>
  <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter android:autoVerify="true">
  <action android:name="android.intent.action.VIEW"/>
  <category android:name="android.intent.category.DEFAULT"/>
  <category android:name="android.intent.category.BROWSABLE"/>
  <data
    android:scheme="https"
    android:host="cloud.appwrite.io"
    android:pathPrefix="/auth/magic-url" />
</intent-filter>
  1. I've implemented Deep Linking on iOS as well, but both on the Simulator and my iPhone I also receive see the "Missing redirect URL" screen. To implement Deel Linking, I followed the instructions on docs.flutter.dev for universal links for iOS:
  • I've added FlutterDeepLinkingEnabled with a Boolean value YES in Xcode.
  • I've set applinks:cloud.appwrite.io as an associated domain in Xcode.

What am I missing? 🫠 Thanks!

TL;DR
Developers are having issues implementing Magic Link Auth on Flutter with missing redirect URL. Suggestions include using Firebase dynamic links as an alternative and setting up custom URL schemes. Pay attention to details like project ID formatting and the key in Info.plist for iOS implementation. Make sure to follow the correct steps and configurations provided in the documentation and community resources for successful implementation.
Elena (@elukashova)
5 May, 2024, 08:48

Routing & sending over the magic link:

TypeScript
// router implementation
final _router = GoRouter(debugLogDiagnostics: true, routes: [
  GoRoute(
    path: '/',
    builder: (BuildContext context, GoRouterState state) {
      return const SplashScreen();
    },
    routes: [
      GoRoute(
        path: 'auth/magic-url',
        builder: (context, GoRouterState state) {
          return OnboardingScreen(
            userId: state.uri.queryParameters['userId'] ?? '',
            secret: state.uri.queryParameters['secret'] ?? '',
          );
        },
      )
    ],
  )
]);

@override
  Widget build(BuildContext context) {
    return MaterialApp.router(
        theme: RemindrTheme.themeData,
        routerConfig: _router,
    );
  }

// creating Magic Link
  void _submit() async {
      try {
        await account.createMagicURLSession(
          userId: ID.unique(),
          email: _enteredEmail,
        );
        _openConfirmationModal();
      } catch (e) {
        print(e);
      }
    return;
  }
Elena (@elukashova)
5 May, 2024, 12:42

Ok, will try implementing it for Android, but still not sure if it's testable on emulator.

From what I saw in the other issues here, it's not, but I'm already very confused.

What about iPhone? I added in Info.plist this:

TypeScript
<array>
  <string>appwrite-callback-[my project id]</string>
</array>

and I still get the same message.

Saurabh
5 May, 2024, 12:44

<key>CFBundleURLSchemes</key> <array> <string>appwrite-callback-auth-[PROJECT_ID]</string> </array>

added the key?

Elena (@elukashova)
5 May, 2024, 12:45

yes

Saurabh
5 May, 2024, 12:47

https://www.appwriters.dev/blog/flutter-password-less-authentication-with-appwrite-magic-url refer this for ios if you don't have the url then do not insert url parameter

Saurabh
5 May, 2024, 12:49

and how did you written the project id appwrite-callback-auth-6r774dfbfggf67676

this is the correct way

many people write it in wrong way like this appwrite-callback-auth-[6r774dfbfggf67676]

Elena (@elukashova)
5 May, 2024, 13:15

I followed the guide, and I continue having the same problem. I tried:

  • on Android emulator;
  • on iOS simulator;
  • in debug mode on my iPhone;
  • through TestFlight on my iPhone.

From what I've read in other similar issues, I have to implement deep linking - and I tried to do it (I created this issue after trying it), but it was causing the exact same problem.

Appwrite just seems not to be done for mobile developers... I don't know what else to do.

Elena (@elukashova)
5 May, 2024, 13:17

Here is a similar issue: https://discord.com/channels/564160730845151244/1147562701007098007... I tried to follow that steps, but still nothing.

Saurabh
5 May, 2024, 13:18

Then repost the problem mentioning @D5

Elena (@elukashova)
5 May, 2024, 13:19

Thank you @Saurabh Actually, it was @D5 who suggested me Appwrite on the Flutter server 😅

Steven
5 May, 2024, 13:29

This might be outdated

Steven
5 May, 2024, 13:30

You must pass a url that will link to your route in the app that takes the secret and user id and calls the update method

Elena (@elukashova)
5 May, 2024, 13:35

I don't have my own domain. What should I write then?

Elena (@elukashova)
5 May, 2024, 13:36

Also, in the documentation it is written If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default. Is it outdated as well?

Steven
5 May, 2024, 13:43

You might need to use a custom url scheme. Look online

Elena (@elukashova)
5 May, 2024, 13:48

To sum up: you have an outdated documentation, you don’t know what people with no domain should do to use your Magic Link Auth (btw, on Firebase it took me just an hour to implement it - with Appwrite I’m about to hit the third day), and I should find a solution online? 😅

D5
5 May, 2024, 13:48

You can use appwrite functions for the deep link URL

D5
5 May, 2024, 13:49

Basically you can get the same as firebase dynamic links: https://github.com/appwrite/dynamic-links

Elena (@elukashova)
5 May, 2024, 13:50

Ok, will give it a try, thank you

D5
5 May, 2024, 13:51

You're welcome. I can build you an example if needed so it's easier to understand 🙂

Elena (@elukashova)
5 May, 2024, 13:52

If it’s not a problem for you, I will really appreciate it, thank you.

Steven
5 May, 2024, 13:56

On firebase, are you using Firebase dynamic links?

Elena (@elukashova)
5 May, 2024, 13:59

Yes.

Steven
5 May, 2024, 14:00
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more