Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get refresh_token results in error #52

Open
remcova opened this issue Sep 4, 2023 · 6 comments
Open

Get refresh_token results in error #52

remcova opened this issue Sep 4, 2023 · 6 comments

Comments

@remcova
Copy link

remcova commented Sep 4, 2023

When I try to get the refresh_token, I use the parameter "prompt" and set it to "consent". Unfortunately, I get the following error in the webview window from Google Firebase:
Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared.

This is my code:

  GoogleSignInArgs({
    required this.clientId,
    required this.redirectUri,
    this.scope = _defaultSignInScope,
    this.immediate = false,
    this.responseType = 'token id_token code',
    this.accessType = 'offline',
  });

  @override
  Map<String, String> buildQueryParameters() {
    return {
      'client_id': clientId,
      'scope': scope,
      // 'immediate': immediate.toString(),
      'response_type': responseType,
      'redirect_uri': redirectUri,
      'access_type': accessType,
      "nonce": generateNonce(),
      "prompt": "consent"
    };
  }

Does anyone experience this issue too? I've tried several things but nothing seems to work so far.

@jungti1234
Copy link

jungti1234 commented Sep 5, 2023

It's similar problem with me I guess?
#50 (comment)

It happened after the consent screen.

@jungti1234
Copy link

jungti1234 commented Sep 12, 2023

I found two reasons for the problem.

  1. You should check for a match between targetUriFragment and uriString even when the navigationType is formSubmitted.

  2. Even if you do No.1, you shouldn't using "contains" for check the match two URLs.
    You should only check that the targetUriFragment exactly matches the baseURL and path of the url (endpoint?).

I rearranged the order of the code a bit to get the uriString first, then get the exactUrl and compare them.

See this: jungti1234@6e376fd

Now it works fine, but I don't know if it's the best code, best way, it would be great to improve it.

@jungti1234
Copy link

jungti1234 commented Sep 12, 2023

And I added the prompt parameter.

See this:
jungti1234@d25cb85

@remcova
Copy link
Author

remcova commented Sep 16, 2023

@jungti1234 Awesome! Thank you for your time to solve this issue. Your solution works. Should we create a pull request for this?

@jungti1234
Copy link

@remcova Yes, I don't mind if you create a pull request.
Umm, Actually I fixed it from to the branch you forked, it seems to be out of sync with the main branch of this repository. So I'm not sure if I should just make my updates a pull request only while keeping the other code.

@remcova
Copy link
Author

remcova commented Sep 25, 2023

@remcova Yes, I don't mind if you create a pull request. Umm, Actually I fixed it from to the branch you forked, it seems to be out of sync with the main branch of this repository. So I'm not sure if I should just make my updates a pull request only while keeping the other code.

I think it would be nice to include all the changes. Especially the refresh token. While pull requests do get approved here, they are not being merged, unfortunately..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants