I've seen this post in github but nothing mentioning Microsoft auth https://github.com/appwrite/appwrite/issues/2591
I solved some errors with the redirect url but now I'm getting the error Param "code" is not optional and not sure how to fix it. I'm currently using the cloud version of appwrite
The error will appear for most auth providers, as when returning to Appwrite url, the code will be missing.
So what I suggest is to upvote the issue, and if you have a self-hosted instance you can try the solution you can find here https://discord.com/channels/564160730845151244/1110920292685053972/1110920292685053972
Thank you! I Will try self hosting and Will upvote the ticket
what's in the url of the page your're on?
The URL from the redirect Uri
would you please share the URL of the page you're on when you see that error?
This is the URL: https://cloud.appwrite.io/v1/account/sessions/oauth2/callback/microsoft/64c3a7469667bd1b8dd5 For a second it's this longer url: https://login.microsoftonline.com/a04e19c7-42ef-4ebe-b06e-84397302b38c/oauth2/v2.0/authorize?client_id=5cda9aac-85d2-4f26-8fc9-66f89a64827c&redirect_uri=https%3a%2f%2fcloud.appwrite.io%2fv1%2faccount%2fsessions%2foauth2%2fcallback%2fmicrosoft%2f64c3a7469667bd1b8dd5&state=%7b%22success%22%3a%22https%3a%5c%2f%5c%2fcloud.appwrite.io%5c%2fv1%5c%2faccount%5c%2fsessions%5c%2foauth2%5c%2fcallback%5c%2fmicrosoft%5c%2f64c3a7469667bd1b8dd5%22%2c%22failure%22%3a%22https%3a%5c%2f%5c%2fcloud.appwrite.io%5c%2fv1%5c%2faccount%5c%2fsessions%5c%2foauth2%5c%2fcallback%5c%2fmicrosoft%5c%2f64c3a7469667bd1b8dd5%22%7d&scope=offline_access+user.read&response_type=code&response_mode=query&sso_nonce=AwABAAEAAAACAOz_BQD0_6kzyOZUm6yc70xV5ubCRlfJMT0ozDo2zi8KWiGLa1glQeICmx8a3uOIDKVMJqmARLWOsdDzwlQIxUiYAofMptYgAA&client-request-id=e0699c50-b7b0-4033-82d1-8e052ecbfce2&mscrid=e0699c50-b7b0-4033-82d1-8e052ecbfce2
I mean after you log in, you end up on the page that says error param code is not optional. What's the URL of that page?
It's the first URL i sent...
Is that really the full url? No query string params?
Yup
That's really weird...can you try the flow again from a browser with the browser dev tools on so you can capture the network logs for the entire flow. Maybe one of the network logs will show some sort of error (from Microsoft)
Ohhhhhhhh what's your flutter code that calls the createOAuth2Session()
Not sure how's the best way to paste the code but here it goes:
import 'package:appwrite/appwrite.dart';
Future microsoftAuth2Session() async { Client client = Client(); Account account = Account(client);
client .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('64c3a7469667bd1b8dd5') // Your project ID ; Future result = account.createOAuth2Session( provider: 'microsoft', success: 'https://cloud.appwrite.io/v1/account/sessions/oauth2/callback/microsoft/64c3a7469667bd1b8dd5', );
result.then((response) { print(response); }).catchError((error) { print(error.response); }); }
So that success youre passing in isn't quite right...is this a flutter mobile app?
Right now I'm trying it in a web session. Currently in flutterflow Should the success url be a url from the flutter app? I put the cloud.appwrite.... url cause otherwise I got this other error: Error 400 Invalid success: URL host must be one of: localhost, cloud.appwrite.io
The success url should redirect the user back to your app. Typically, devs have to set up this auth page and the success url should point to this page: https://github.com/appwrite/sdk-for-flutter/tree/master#web
Thank you for the link
Recommended threads
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...
- I'm experiencing a critical bug on Appwr...
Hey <@870607367597850624> team / support 👋 I'm experiencing a critical bug on Appwrite Cloud that's blocking my production Flutter app. I've already filed GitH...