definitelytyped-firefox-webext-browser icon indicating copy to clipboard operation
definitelytyped-firefox-webext-browser copied to clipboard

`browser.identity.getAuthToken` resolves with `AccountInfo[]` instead of string

Open fregante opened this issue 4 years ago • 4 comments

This is a Chrome-only API: https://developer.chrome.com/docs/extensions/reference/identity/#method-getAuthToken

Currently mistyped as

    /**
     * Gets an OAuth2 access token using the client ID and scopes specified in the oauth2 section of manifest.json.
     * @deprecated Unsupported on Firefox at this time.
     */
    function getAuthToken(details?: _GetAuthTokenDetails): Promise<AccountInfo[]>;

It should be:

    function getAuthToken(details?: _GetAuthTokenDetails): Promise<string>;

fregante avatar Jun 26 '21 10:06 fregante

Yep, i see. Should be fixed when https://github.com/DefinitelyTyped/DefinitelyTyped/pull/54359 merges ^^

jsmnbom avatar Jul 07 '21 19:07 jsmnbom

Oh nevermind, i misunderstood, gimme a sec.

jsmnbom avatar Jul 07 '21 19:07 jsmnbom

Hmm... not totally sure how to handle this one, since according to https://developer.chrome.com/docs/extensions/reference/identity/#method-getAuthToken, it can return two values? Promise<string, string>, would be ideal, but that's obviously not possible... Should i just leave it as Promise for now, and then we'll see how firefox solves the problem in the future and fix it then?

jsmnbom avatar Jul 07 '21 19:07 jsmnbom

Indeed, perhaps it should just be removed for the time being because it's not part of the browser.* API

fregante avatar Jul 08 '21 06:07 fregante

I moved to @types/chrome and @types/webextensions-polyfill

fregante avatar Feb 09 '23 19:02 fregante