Back

[SOLVED] Github OAuth Redirects to New Page Creating Two tabs

  • 0
  • Flutter
  • Web
  • Cloud
Drake
24 Jul, 2023, 20:17

Yes?

TL;DR
The user had an issue with Github OAuth redirecting to a new page and creating two tabs. It seems that `account.createOAuth2Session()` never resolved because it only resolves if the message was received from the same origin. The solution was suggested to redirect to a success URL using the `window_location_href` package. The user also asked if it was possible to refresh the Flutter application from the `auth.html` file. There was a question about making Flutter consistently listen to Appwrite changes. Another issue was that the `CheckStep()` function was not being called when navigating to a new page. The solution suggested setting a breakpoint to see
Drake
24 Jul, 2023, 20:19

Btw, it's best to be direct rather than just stating you have a problem

Aarush Acharya
24 Jul, 2023, 20:21

this is what happens when it redirects it looses connection to the previous application and the code written in it after that does not work

Aarush Acharya
24 Jul, 2023, 20:21

so the state is not updated until I Reload the application

Aarush Acharya
24 Jul, 2023, 20:22

apologies would that form next time onwards

Drake
24 Jul, 2023, 20:32

Can you set a breakpoint to see when your check step function is called?

Aarush Acharya
24 Jul, 2023, 20:52
Aarush Acharya
24 Jul, 2023, 20:52

The second CheckStep() isnt called as we navigate to a new page

Aarush Acharya
24 Jul, 2023, 21:00

Hey @Steven can I make flutter consistantly listen to appwrite changes

Aarush Acharya
24 Jul, 2023, 21:00

if that is possible i believe I can solve this

Aarush Acharya
24 Jul, 2023, 21:01

OR

Aarush Acharya
24 Jul, 2023, 21:01

If possible can I refresh my flutter application from the auth.html

Drake
24 Jul, 2023, 21:02

i think the problem is you're redirecting to vercel, but you're running from localhost.

for your success url, I recommend installing the window_location_href package and doing something like: https://github.com/appwrite/playground-for-flutter/blob/ad30fb232a223e118c9429ac1df75f856b6a1d9d/lib/main.dart#L294

Aarush Acharya
24 Jul, 2023, 21:07

alright would look into it

Aarush Acharya
24 Jul, 2023, 21:09

Yep you were right Deployed on vercel and tested worked

Aarush Acharya
24 Jul, 2023, 21:09

thanks a lot

Aarush Acharya
24 Jul, 2023, 21:09

Would use this

Aarush Acharya
24 Jul, 2023, 21:12

But just one last thing

Aarush Acharya
24 Jul, 2023, 21:12

I did not understand why the error was there

Drake
24 Jul, 2023, 21:13

account.createOAuth2Session() never resolved because it only resolves if the message was received from the same origin: https://github.com/ThexXTURBOXx/flutter_web_auth_2/blob/ff927eb20fc89389700c11558fbc921727e4491f/flutter_web_auth_2/lib/src/flutter_web_auth_2_web.dart#L52

Aarush Acharya
24 Jul, 2023, 21:13

even if we did redirect to vercel deployed auth.js but in a new tab when the window closes shouldnt it mean the function call should return and the control goes back to local host

Aarush Acharya
24 Jul, 2023, 21:14

Ohh Alright thanks

Aarush Acharya
24 Jul, 2023, 21:14

Cool

Drake
24 Jul, 2023, 21:15
Aarush Acharya
24 Jul, 2023, 21:58

Also this made things quite easier thanks just implemented

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