Skip to content

identity.launchWebAuthFlow() is not opening provided URL in Android Edge #364

@kurrx

Description

@kurrx

Description

When using identity.launchWebAuthFlow() (MDN) in Android Edge throws following error in console and flow is not started:

# Most of the time it throws this error:
Couldn't create a browser window to display an authorization page

# Rarely but it might throw this error too:
identity.launchWebAuthFlow not implemented

In desktop Edge it works fine and as expected.

I suppose it's bug because in Supported APIs page in identity row Android is listed in platforms.

I appreciate if you provide any workaround to mitigate this issue.

Steps to Reproduce

  1. Place all of the files below in one directory
  2. Create crx file from this directory
  3. Enable developer mode in Android Edge
  4. Go to Settings -> Developer Options -> Install extension by crx
  5. Select crx file
  6. Open extension's popup page
  7. Click on button
  8. Error thrown in console

manifest.json:

{
    "name": "OAuth Extension",
    "description": "Test Identity API",
    "version": "1.0.0",
    "manifest_version": 3,
    "action": {
        "default_popup": "index.html"
    },
    "permissions": [
        "identity"
    ]
}

index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            width: 300px;
            height: 300px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            row-gap: 10px;
        }

        button {
            background: black;
            color: #ffffff;
            padding: 10px 20px;
            border: none;
            cursor: pointer;
            transition: all 0.3s ease;
            border-radius: 30px;
            font-weight: 700;
        }

        button:hover {
            background: #488202;
        }
    </style>
</head>
<body>
    <h1>Identity API Login</h1>
    <button id="auth-btn">identity.launchWebAuthFlow()</button>
    <script type="text/javascript" src="./index.js"></script>
</body>
</html>

index.js:

async function initiateOAuthFlow() {
    // Get the redirect URL for the OAuth flow
    const redirectUrl = chrome.identity.getRedirectURL('callback');

    // Initiate the OAuth flow
    const responseUrl = await chrome.identity.launchWebAuthFlow({
        url: 'https://example.org?redirect_url=' + encodeURIComponent(redirectUrl),
        interactive: true,
        abortOnLoadForNonInteractive: true,
        timeoutMsForNonInteractive: 60000,
    });

    // When the OAuth flow is complete, the response URL will contain the access token
    console.log('Response URL:', responseUrl);
}

document.getElementById('auth-btn').onclick = initiateOAuthFlow;

Platform Info

Tested on:

  • Browser: Microsoft Edge 141.0.3495.0 (Official build) canary (64-bit)
  • Chromium version: 141.0.7342.0
  • OS: Android 16 (Build/BP22.250221.010)
  • JavaScript engine: V8 14.1.1
  • User Agent: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36 EdgA/141.0.0.0

Metadata

Metadata

Assignees

Labels

APIFor any API related issuesBugthe issue is a code defect that should be fixedTrackedthe issue is valid and tracked on our backlog.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions