oauth2_client
oauth2_client copied to clipboard
Web auth doesn't retrieve the access_token
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?