protectedResourceMetadataUrls function
Where the Protected Resource Metadata of serverUrl may be, in the order
to try: at the server's path, then at the root (RFC 9728 ยง3.1).
Implementation
List<Uri> protectedResourceMetadataUrls(String serverUrl) {
final u = Uri.parse(serverUrl);
const wellKnown = '/.well-known/oauth-protected-resource';
final path = u.path.endsWith('/') ? u.path.substring(0, u.path.length - 1) : u.path;
return [
if (path.isNotEmpty) u.replace(path: '$wellKnown$path', query: null, fragment: null),
u.replace(path: wellKnown, query: null, fragment: null),
];
}