MCPcopy Index your code
hub / github.com/mailvelope/mailvelope / getAuthCode

Function getAuthCode

src/modules/gmail.js:235–261  ·  view source on GitHub ↗
(email, scopes = chrome.runtime.getManifest().oauth2.scopes, prompt)

Source from the content-addressed store, hash-verified

233}
234
235async function getAuthCode(email, scopes = chrome.runtime.getManifest().oauth2.scopes, prompt) {
236 const redirectURL = chrome.identity.getRedirectURL();
237 const state = getUUID();
238 const auth_params = {
239 access_type: 'offline',
240 client_id: CLIENT_ID,
241 include_granted_scopes: true,
242 login_hint: email,
243 redirect_uri: redirectURL,
244 response_type: 'code',
245 scope: scopes.join(' '),
246 state
247 };
248 if (prompt) {
249 auth_params.prompt = prompt;
250 }
251 const url = `${GOOGLE_API_HOST}/o/oauth2/v2/auth?${new URLSearchParams(Object.entries(auth_params))}`;
252 const responseURL = await chrome.identity.launchWebAuthFlow({url, interactive: true});
253 const search = new URL(responseURL).searchParams;
254 if (search.get('state') !== state) {
255 throw new Error('oauth2/v2/auth: wrong state parameter');
256 }
257 return {
258 code: search.get('code'),
259 prompt: search.get('prompt')
260 };
261}
262
263async function getAuthToken(email, scopes = chrome.runtime.getManifest().oauth2.scopes, prompt) {
264 const redirectURL = chrome.identity.getRedirectURL();

Callers 1

authorizeFunction · 0.85

Calls 2

getUUIDFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected