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

Web auth doesn't retrieve the access_token #167

Open
benjaminhorner opened this issue Jun 29, 2023 · 0 comments
Open

Web auth doesn't retrieve the access_token #167

benjaminhorner opened this issue Jun 29, 2023 · 0 comments

Comments

@benjaminhorner
Copy link

I have implemented oAuth2 for both Android and iOS and they are both working fine.

I am now trying to do the same for Flutter Web but the token does not seem to be passed to the web app.

I have a login button that successfully opens the auth popup and redirects to the call back HTML page which is as follows:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Scorefun</title>
    <link rel="icon" href="./favicon.ico" type="image/x-icon" />
  </head>
  <body>
    <main>
      <h1>Loading…</h1>
    </main>
  </body>
  <script>
    window.onload = function () {
     const url = new URL(document.URL);
        const urlSearchParams = url.searchParams;
        const access_token = encodeURI(urlSearchParams.get("code"));
        const returnUrl =  window.location.href;
        if (access_token) {
         window.opener.postMessage(
             returnUrl,
              window.location.origin
            );
  </script>
</html>

I have also tried using the customUriScheme (scheme://?code=XYZ…) but to no avail.

I get a 200 HTTP response status in the web app but no token or anything else.

What am I missing? Does the returnUrl have to have a certain format? Does the token necessarily have to have "code" as query parameter? How does the plugin retrieve the token from the URL?

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

1 participant