extractFileIdFromSharableLink method
Implementation
@override
Future<String?> extractFileIdFromSharableLink(Uri shareLink) async {
final accessToken = await DefaultTokenManager(
tokenEndpoint: OneDrive.tokenEndpoint,
clientID: client.clientID,
redirectURL: client.redirectURL,
scope: client.scopes,
).getAccessToken();
final encoded = encodeShareUrl(shareLink);
final response = await http.get(
Uri.parse('https://graph.microsoft.com/v1.0/shares/u!$encoded/driveItem'),
headers: {
'Authorization': 'Bearer $accessToken',
},
);
if (response.statusCode == 200) {
final json = jsonDecode(response.body);
return json['id']; // actual OneDrive item ID
} else {
throw Exception(
'Failed to resolve item ID: ${response.statusCode}, ${response.body}');
}
}