You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class AuthController extends BaseGetXController {
AuthController(this.oauth, this.config); // this.storage,
final AadOAuth oauth;
// final GetStorage storage;
final Config config;
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you still think this issue is needed, reopen it again.
If access token is expired so how to manage with refresh token and work through the app.
My code :
main.dart file :
final GlobalKey navigatorKey = GlobalKey();
late final AuthController authController;
final config = Config(
// tenant: '416a0629-c2f6-468c-b028-ec1aaaaf6e37',
tenant: 'heartid',
clientId: '45fff3bf-c5f3-4ad7-a227-e09ee495bc91',
scope:
'openid offline_access https://heartid.onmicrosoft.com/80487dfc-2b55-408d-a998-4c7eb488f699/access_as_user',
redirectUri: 'https://login.live.com/oauth20_desktop.srf',
isB2C: true,
navigatorKey: navigatorKey,
policy: 'B2C_1_CustomerSignin',
tokenIdentifier: 'UNIQUE IDENTIFIER A',
webUseRedirect: true,
loader: const Center(child: CircularProgressIndicator()),
);
final oauth = AadOAuth(config);
await GetStorage.init();
//final storage = GetStorage();
authController = AuthController(oauth, config);
authcontroller.dart file
class AuthController extends BaseGetXController {
AuthController(this.oauth, this.config); // this.storage,
final AadOAuth oauth;
// final GetStorage storage;
final Config config;
//RxBool isAuthenticated = false.obs;
RxString accessToken = ''.obs;
RxString refreshToken = ''.obs;
final box = GetStorage();
Future signIn() async {
try {
final result = await oauth.login();
await result.fold(
(failure) {
if (failure.errorType ==
ErrorType.accessDeniedOrAuthenticationCanceled) {
print('Access denied or authentication canceled.');
Get.snackbar(
'Authentication Error',
'Access denied or authentication canceled.',
snackPosition: SnackPosition.BOTTOM,
);
} else {
print('Failed to sign in: ${failure.errorType}');
Get.snackbar(
'Authentication Error',
'Failed to sign in: ${failure.errorType}',
snackPosition: SnackPosition.BOTTOM,
);
}
},
(token) async {
//isAuthenticated.value = true;
accessToken.value = token.accessToken!;
refreshToken.value = token.refreshToken!;
await boxStorage.setString(
GetStorageHelper.token,
accessToken.toString(),
);
}
void signOut() {
oauth.logout();
//isAuthenticated.value = false;
//accessToken.value = '';
// storage.remove('accessToken');
Get.offAllNamed(Routes.login);
}
Future getUserData(String token) async {
// await authController.signIn();
}
@OverRide
void onInit() {
super.onInit();
// accessToken.value = storage.read('accessToken') ?? '';
// isAuthenticated.value = accessToken.isNotEmpty;
}
}
Can you check the code and provide me a solution.
The text was updated successfully, but these errors were encountered: