Back

oAuth2 with native Java

  • 0
  • Android
  • Auth
Naos
13 Sep, 2024, 13:39

Im trying to get this going but no matter what I put in the redirect urls I keep getting the same error "URL Host must be one of: -list of web platforms added in appwrite-"

  • if I put them to "appwrite-callback-[projectid]" I get an error from the appwrite server that it doesnt conform the my set web platform
  • if I put them to "null" it interprets them as empty / missing
  • If I just not set them it thinks I want to set the scopes variable as the redirect url and complains
  • "com.yourdomain.app://oauth2redirect", / doesnt work
  • Localhost doesnt work
  • etc public static void performOAuth(AppCompatActivity activity) { List<String> scopes = Arrays.asList("User.Read", "User.ReadBasic.All"); // Adjust scopes as needed account.createOAuth2Session( activity, OAuthProvider.MICROSOFT, null, null, scopes, new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); return; } Log.d("Appwrite", result.toString()); }) ); }
TL;DR
Issue with setting redirect URLs for oAuth2 in native Java with Appwrite. Developers facing errors due to incorrect redirect URLs. URLs like "appwrite-callback-[projectid]", "null", and localhosts not working. Solution: Make sure to set valid redirect URLs in the Appwrite server console. Double-check URLs and verify they match the allowed web platforms list in Appwrite.
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