obtainAccessToken method

Future obtainAccessToken (
  1. {String scope}
)

Obtains an access token for the specified resource scope from the MobileFirst authorization server. Returns an AccessToken for the scope provided. If an error occurs, an object of type MFResponse is returned.

Implementation

Future<dynamic> obtainAccessToken({String scope}) async {
  final Map response = await _channel.invokeMethod(
      WLAUTHORIZATIONMANAGER_OBTAINACCESSTOKEN,
      <String, dynamic>{SCOPE: scope});
  final MFResponse mfResponse = MFResponse(mfResponse: response);
  if ((mfResponse.errorMsg?.isEmpty ?? true) ||
      (mfResponse.errorCode?.isEmpty ?? true)) {
    return AccessToken(accessToken: response);
  } else {
    throw mfResponse;
  }
}