loginForAccessToken method
Implementation
Future<String> loginForAccessToken(
{PreferredSizeWidget? appBar, bool destroySession = true}) async {
final authorizationData = await showDialog(
context: context,
builder: (context) => LinkedInWebView(
clientId: clientId,
clientSecret: clientSecret,
redirectUri: redirectUri,
destroySession: destroySession,
)).catchError((error) {
if (error is AuthorizationErrorResponse)
throw error;
else
throw AuthorizationErrorResponse(errorDescription: error.toString());
});
if (authorizationData == null)
throw AuthorizationErrorResponse(errorDescription: 'unknown error');
if (authorizationData is AuthorizationSuccessResponse) {
accessToken = await getAccessToken(
clientId: clientId,
clientSecret: clientSecret,
redirectUri: redirectUri,
code: authorizationData.code!)
.catchError((error) {
if (error is AuthorizationErrorResponse)
throw error;
else
throw AuthorizationErrorResponse(errorDescription: error.toString());
});
return accessToken!;
} else {
throw (authorizationData as AuthorizationErrorResponse);
}
}