Closed tratum closed 3 months ago
This is not a package issue but a personal problem i think so if anyone can help much appreciated @loetsphi or @josemiguelvarela
Can anyone help
If Anyone else is also having the Same Problem then NO Need to worry it's resolved
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
const storage = FlutterSecureStorage();
final dio = Dio();
Future<void> getUserProfile() async {
final accessToken = await storage.read(key: 'access_token');
if (accessToken != null) {
final response = await dio.get(
'https://graph.microsoft.com/v1.0/me', //---------------------------------Change Made in The Line
options: Options(headers: {
'Authorization': 'Bearer $accessToken',
}),
);
if (response.statusCode == 200) {
// Handle the response
debugPrint('-------------Response body: ${response.data}');
} else {
// Handle the error
debugPrint('Request failed with status: ${response.statusCode}.');
}
} else {
debugPrint('Access token not found.');
}
}
When using the aad_oauth package to authenticate a Microsoft user and obtaining the accessToken successfully, attempts to retrieve user information result in a 403 error.
Source Codes used:
aad_oauth configuration
Getting User Profile
Final Operation
*Azure Portal