@@ -219,7 +219,11 @@ async function getTotp(text: string) {
219219}
220220
221221function getBackupToken ( service : string ) {
222- if ( navigator . userAgent . indexOf ( "Chrome" ) !== - 1 && service === "drive" ) {
222+ if (
223+ navigator . userAgent . indexOf ( "Chrome" ) !== - 1 &&
224+ navigator . userAgent . indexOf ( "Edg" ) === - 1 &&
225+ service === "drive"
226+ ) {
223227 chrome . identity . getAuthToken (
224228 {
225229 interactive : true ,
@@ -233,18 +237,26 @@ function getBackupToken(service: string) {
233237 ) ;
234238 } else {
235239 let authUrl = "" ;
240+ let redirUrl = "" ;
236241 if ( service === "dropbox" ) {
242+ redirUrl = encodeURIComponent ( chrome . identity . getRedirectURL ( ) ) ;
237243 authUrl =
238244 "https://www.dropbox.com/oauth2/authorize?response_type=token&client_id=" +
239245 getCredentials ( ) . dropbox . client_id +
240246 "&redirect_uri=" +
241- encodeURIComponent ( chrome . identity . getRedirectURL ( ) ) ;
247+ redirUrl ;
242248 } else if ( service === "drive" ) {
249+ if ( navigator . userAgent . indexOf ( "Edg" ) !== - 1 ) {
250+ redirUrl = encodeURIComponent ( "https://authenticator.cc/oauth-edge" ) ;
251+ } else {
252+ redirUrl = encodeURIComponent ( "https://authenticator.cc/oauth" ) ;
253+ }
254+
243255 authUrl =
244256 "https://accounts.google.com/o/oauth2/v2/auth?response_type=code&access_type=offline&client_id=" +
245257 getCredentials ( ) . drive . client_id +
246258 "&scope=https%3A//www.googleapis.com/auth/drive.file&prompt=consent&redirect_uri=" +
247- encodeURIComponent ( "https://authenticator.cc/oauth" ) ;
259+ redirUrl ;
248260 }
249261 chrome . identity . launchWebAuthFlow (
250262 { url : authUrl , interactive : true } ,
@@ -296,7 +308,9 @@ function getBackupToken(service: string) {
296308 getCredentials ( ) . drive . client_secret +
297309 "&code=" +
298310 value +
299- "&redirect_uri=https://authenticator.cc/oauth&grant_type=authorization_code"
311+ "&redirect_uri=" +
312+ redirUrl +
313+ "&grant_type=authorization_code"
300314 ) ;
301315 xhr . setRequestHeader ( "Accept" , "application/json" ) ;
302316 xhr . setRequestHeader (
@@ -365,7 +379,10 @@ chrome.runtime.onInstalled.addListener(async details => {
365379
366380 let url : string | null = null ;
367381
368- if ( navigator . userAgent . indexOf ( "Chrome" ) !== - 1 ) {
382+ if (
383+ navigator . userAgent . indexOf ( "Chrome" ) !== - 1 &&
384+ navigator . userAgent . indexOf ( "Edg" ) === - 1
385+ ) {
369386 url = "https://authenticator.cc/docs/en/chrome-issues" ;
370387 }
371388
0 commit comments