1

I'm trying to connect my Flutter application with the Okta API, but unfortunately I have not been able to connect them. Here is an example flow for the login:

  1. The first step is to use the authenticate API in order to authenticate the user using his username and password in order to get in return a sessionToken.

ex:

var authenticationResponse = await client.post("https://$_oktaDomain/api/v1/authn", data: {
      "username": username,
      "password": password,
      "options": {"multiOptionalFactorEnroll": false, "warnBeforePasswordExpired": false}
    });
  1. The second step is to exchange this sessionToken for an access_token using the authorization API

ex:

var url = "https://$_oktaDomain/oauth2/$_authServerId/v1/authorize?client_id=$_clientId&sessionToken=${authenticationResponseData["sessionToken"]}&redirect_uri=$_redirectUri&scope=$_scope&response_type=token&state=$state&nonce=$nonce";
var authorizationResponse2 = await client.get(url);

When calling this endpoint we need to provide a redirect_uri. I have tried to implement a custom url scheme (like com.okta.paketo-com-org-636) in order for the http client to redirect back to my application. But unfortunately that method seems to not work as it is not a valid URI for the http client.

Is there any way to achieve this without using a webview ?

Thanks in advance.

Jonathan.

4

0 回答 0