sso method
- String serviceCode
override
Performs single sign-on (SSO) to authenticate with a target NTUT service.
This method must be called after login to obtain session cookies for other NTUT services (Course Service, Score Service, or I-School Plus).
The SSO process:
- Fetches an SSO form from Portal with the service code
- Submits the form to the target service
- Sets the necessary authentication cookies for that service
All services share the same cookie jar, so SSO only needs to be called once per service during a session.
Throws an Exception if the SSO form is not found (user may not be logged in).
Implementation
@override
Future<void> sso(String serviceCode) async {
if (serviceCode != PortalServiceCode.iSchoolPlusService.code) {
return _withPortalLocaleLock(() => _performSso(serviceCode));
}
final cancelToken = CancelToken();
final timer = Timer(
_iSchoolSsoTimeout,
() => cancelToken.cancel('I-School Plus SSO timed out'),
);
try {
final operation = _withPortalLocaleLock(
() => _performSso(serviceCode, cancelToken: cancelToken),
);
await Future.any([
operation,
cancelToken.whenCancel.then((error) => throw error),
]);
} finally {
timer.cancel();
}
}