Back

oauth2 login with microsoft

  • 0
  • Self Hosted
  • Auth
  • Flutter
Kuromory
3 Jun, 2024, 14:33

I created a flutter/desktop app where I want to create a oauth2 login with a microsoft account, but I get an "error" so that I can login in a browser but the "success" is only in the browser and not in the desktop app... can someone tell me how I need to create the login process in flutter so it works on desktop/android/web etc.?

TL;DR
Developers faced chaos with Microsoft login errors on their web and Windows platforms in their self-hosted VPS, while cloud deployment worked. Even after various attempts and reinstalls, the issue persisted with login failures and error 500. The solution that eventually worked was enabling Access Tokens and ID Tokens in Azure authentication settings, setting appwrite to ports 80/443, and utilizing the success parameter in the Flutter function for OAuth2 sessions with Microsoft. This setup enabled successful logins without errors.
Kuromory
3 Jun, 2024, 14:35

here is the code:

TypeScript
 await _account.createOAuth2Session(
        provider: OAuthProvider.microsoft,
        success:
            'http://localhost:8443/v1/account/sessions/oauth2/callback/microsoft/65eef06d684381b3ebee',
      );
Kuromory
3 Jun, 2024, 14:45

and as return I get following (in browser)

TypeScript
https://localhost/v1/account/sessions/oauth2/callback/microsoft/65eef06d684381b3ebee?code=0.AXoAMHVysJcPIE2S...
D5
3 Jun, 2024, 14:54

The success URL should be a part/route of your flutter app and not the appwrite instance

Kuromory
3 Jun, 2024, 14:59

so it should go like this http://localhost/home ? even when it is not a web app?

Kuromory
4 Jun, 2024, 09:06

so how do I logout? πŸ˜„

D5
4 Jun, 2024, 09:07

That way. You're doing it correctly

Kuromory
4 Jun, 2024, 09:10

else I get the error 500

Kuromory
4 Jun, 2024, 09:10

hmm so what could be the problem? it is like a 50/50 it works πŸ˜„

Kuromory
5 Jun, 2024, 06:59

@D5 do you have an Idea why I get this error?

D5
5 Jun, 2024, 10:57

When do you get this? Do you have or can find some replication pattern or steps?

Kuromory
5 Jun, 2024, 13:02

not really, just when I sucessfully login in Microsoft and it redirects to appwrite...

Kuromory
5 Jun, 2024, 14:29

@D5 I really don't know what is wrong with my appwrite... now I also can't login with just email/password... error is: flutter: AppwriteException: general_unauthorized_scope, User (role: guests) missing scope (account) (401)

Kuromory
5 Jun, 2024, 14:29

I event totally reinstalled appwrite but still have this problem...

D5
5 Jun, 2024, 14:30

That error means that you're logged out...

Kuromory
5 Jun, 2024, 14:32

yeah, but I get this after dart // works await _account.createEmailPasswordSession( email: event.email, password: event.password, ); // throws error final user = await _account.get();

Kuromory
5 Jun, 2024, 14:39

@D5 I mean it worked like for weeks now and just today it does not work anymore? πŸ˜„

D5
5 Jun, 2024, 14:41

Because you deleted your appwrite instance?

Kuromory
5 Jun, 2024, 14:41

no, I deleted it because I thought that would fix it... just reinstalled everything...

Kuromory
5 Jun, 2024, 14:42

I mean with cloud it works... just not with my localhost... I even changed the ports to 80/443...

Kuromory
5 Jun, 2024, 14:44

@D5 should i run the update form 1.5.5 to 1.5.7? it might helps? 🀷

D5
5 Jun, 2024, 14:59

It could. However It think it's because of the domain

D5
5 Jun, 2024, 14:59

I'm self-hosting in a cheap VPS and it works like in cloud

Kuromory
5 Jun, 2024, 14:59

@D5 okey upgraded it but did not help but I found out now we are in total chaos πŸ˜„ on web:

  • email/password login works
  • microsoft login does NOT work (error 500) on Desktop (Windows)
  • email/password login does NOT work (guest error)
  • microsoft login does NOT work (error 500)
Kuromory
5 Jun, 2024, 15:00

you mean localhost?

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