Skip to content

Commit

Permalink
fix: Set fallback url for authorisation server metadata #3124
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Nov 28, 2024
1 parent 8faa499 commit c4771ce
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions packages/oidc4vc/lib/src/oidc4vc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1710,8 +1710,12 @@ class OIDC4VC {
var url = '$baseUrl/.well-known/openid-configuration';

final oAuthUrl = '$baseUrl/.well-known/oauth-authorization-server';
var fallbackUrl = oAuthUrl;

if (useOAuthAuthorizationServerLink) {
url = '$baseUrl/.well-known/oauth-authorization-server';
fallbackUrl = url;
url = oAuthUrl;
}

try {
Expand All @@ -1727,7 +1731,21 @@ class OIDC4VC {

return data;
} catch (e) {
throw Exception('AUTHORIZATION_SERVER_METADATA_ISSUE');
try {
final response = await dioGet(
fallbackUrl,
isCachingEnabled: isCachingEnabled,
dio: dio,
secureStorage: secureStorage,
);
final data = response is String
? jsonDecode(response) as Map<String, dynamic>
: response as Map<String, dynamic>;

return data;
} catch (e) {
throw Exception('AUTHORIZATION_SERVER_METADATA_ISSUE');
}
}
}

Expand Down

0 comments on commit c4771ce

Please sign in to comment.