teranetsrl / oauth2_client

Simple Dart library for interacting with OAuth2 servers.
BSD 2-Clause "Simplified" License
96 stars 112 forks source link

Invalid argument (callbackUrlScheme): must be a valid URL scheme: "com.test.app" #158

Open Aaqib22 opened 1 year ago

Aaqib22 commented 1 year ago

i am unable to run this code

` static Future fetchOutlookCalender() async { var client = OAuth2Client( authorizeUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize', tokenUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/token', redirectUri: 'msauth://com.test.app/gYfucgrOlZ3FLWgYctqk1bCxZbo%3D', customUriScheme: 'com.test.app');

var token = await client.getTokenWithAuthCodeFlow(
    clientId: 'f865f294-3647-43d7-bc6e-f726f06nnno56be',
    scopes: ['openid profile offline_access user.read calendars.read']);
log('accesstoken:' '${token.accessToken}');

}`

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument (callbackUrlScheme): must be a valid URL scheme: "com.test.app"

okrad commented 1 year ago

Hi @Aaqib22, the customUriScheme must correspond to the scheme of the redirectUri, in your case "msauth". Hope it helps!