|
|
@ -72,6 +72,10 @@ class PlexOAuth {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public preparePopup(): void {
|
|
|
|
|
|
|
|
this.openPopup({ title: 'Plex Auth', w: 600, h: 700 });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async login(): Promise<string> {
|
|
|
|
public async login(): Promise<string> {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
this.initializeHeaders();
|
|
|
|
this.initializeHeaders();
|
|
|
@ -98,12 +102,12 @@ class PlexOAuth {
|
|
|
|
'context[device][layout]': 'desktop',
|
|
|
|
'context[device][layout]': 'desktop',
|
|
|
|
code: this.pin.code,
|
|
|
|
code: this.pin.code,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.openPopup({
|
|
|
|
|
|
|
|
url: `https://app.plex.tv/auth/#!?${this.encodeData(params)}`,
|
|
|
|
if (this.popup) {
|
|
|
|
title: 'Plex Auth',
|
|
|
|
this.popup.location.href = `https://app.plex.tv/auth/#!?${this.encodeData(
|
|
|
|
w: 600,
|
|
|
|
params
|
|
|
|
h: 700,
|
|
|
|
)}`;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return this.pinPoll();
|
|
|
|
return this.pinPoll();
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
@ -150,12 +154,10 @@ class PlexOAuth {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private openPopup({
|
|
|
|
private openPopup({
|
|
|
|
url,
|
|
|
|
|
|
|
|
title,
|
|
|
|
title,
|
|
|
|
w,
|
|
|
|
w,
|
|
|
|
h,
|
|
|
|
h,
|
|
|
|
}: {
|
|
|
|
}: {
|
|
|
|
url: string;
|
|
|
|
|
|
|
|
title: string;
|
|
|
|
title: string;
|
|
|
|
w: number;
|
|
|
|
w: number;
|
|
|
|
h: number;
|
|
|
|
h: number;
|
|
|
@ -199,9 +201,6 @@ class PlexOAuth {
|
|
|
|
if (newWindow) {
|
|
|
|
if (newWindow) {
|
|
|
|
newWindow.focus();
|
|
|
|
newWindow.focus();
|
|
|
|
this.popup = newWindow;
|
|
|
|
this.popup = newWindow;
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
|
|
newWindow.location.href = url;
|
|
|
|
|
|
|
|
}, 1500);
|
|
|
|
|
|
|
|
return this.popup;
|
|
|
|
return this.popup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|