internal static MobileConnectStatus StartAuthentication(IAuthenticationService authentication, DiscoveryResponse discoveryResponse, string encryptedMSISDN, string state, string nonce, MobileConnectConfig config, MobileConnectRequestOptions options) { if (!IsUsableDiscoveryResponse(discoveryResponse)) { return(MobileConnectStatus.StartDiscovery()); } StartAuthenticationResponse response; try { string clientId = discoveryResponse.ResponseData.response.client_id ?? config.ClientId; string authorizationUrl = discoveryResponse.OperatorUrls.AuthorizationUrl; SupportedVersions supportedVersions = discoveryResponse.ProviderMetadata?.MobileConnectVersionSupported; AuthenticationOptions authOptions = options?.AuthenticationOptions ?? new AuthenticationOptions(); authOptions.ClientName = discoveryResponse.ApplicationShortName; response = authentication.StartAuthentication(clientId, authorizationUrl, config.RedirectUrl, state, nonce, encryptedMSISDN, supportedVersions, authOptions); } catch (MobileConnectInvalidArgumentException e) { Log.Error(() => $"An invalid argument was passed to StartAuthentication arg={e.Argument}"); return(MobileConnectStatus.Error(ErrorCodes.InvalidArgument, string.Format("An argument was found to be invalid during the process. The argument was {0}.", e.Argument), e)); } catch (Exception e) { Log.Error(() => $"A general error occurred in AttemptDiscoveryAfterOperatorSelection state={state} nonce={nonce} authUrl={discoveryResponse.OperatorUrls.AuthorizationUrl}"); return(MobileConnectStatus.Error(ErrorCodes.Unknown, "An unknown error occured while generating an authorization url", e)); } return(MobileConnectStatus.Authentication(response.Url, state, nonce)); }