Closed 808thlife closed 3 days ago
@808thlife What have you done to solve this issue? I'm facing similar issue
@anderscheow I just separated authorization and token exchange logic. Make sure you are calling token api endpoint after authorization phase.
This is how i implemented it (it's not the full code)
final AuthorizationResponse authResponse = await appAuth.authorize(
AuthorizationRequest(
"ad6jnO5ZuqIbrSQEtF05xA67Fc0JW7JJ6vQNYzuW",
"com.app.app://oauthredirect",
discoveryUrl: API.oauth2DiscoveryUrl().toString(),
promptValues: ["login"],
scopes: ['openid'],
nonce: "ad6jnO5ZuqIbrSQEtF05xA67Fc0JW7JJ6vQNYzuW",
allowInsecureConnections: true,
),
);
log("Authorization: ${authResponse.toString()}");
if (authResponse.authorizationCode != null) {
final TokenResponse result = await appAuth.token(
TokenRequest(
"ad6jnO5ZuqIbrSQEtF05xA67Fc0JW7JJ6vQNYzuW",
"com.app.app://oauthredirect",
authorizationCode: authResponse.authorizationCode,
codeVerifier: authResponse.codeVerifier,
grantType: "authorization_code",
scopes: ['openid'],
nonce: "ad6jnO5ZuqIbrSQEtF05xA67Fc0JW7JJ6vQNYzuW",
discoveryUrl: API.oauth2DiscoveryUrl().toString(),
allowInsecureConnections: true,
),
);
I'm using
flutter_appauth
library for implementing oauth2 with custom web service.Problem: When the user signs in, in a clear browser without cache, cookies etc. (meaning that there are no active session in it), it doesn't redirect the user to the app. However, when the browser already has an active session (user can obtain it if he provides correct credentials and then exits the browser) redirection works perfectly fine.
So basically this is the flow for better understanding:
This is the code
Login
build.gradle
I've already checked if redirect schemes are similar with the backend and everything is fine.