Skip to content

Commit a27f622

Browse files
ComputerEliteComputerElite
authored andcommitted
Update login code to use cookies and developer.oculus.com, make logout and login more reliable
1 parent 38d9e66 commit a27f622

6 files changed

Lines changed: 43 additions & 37 deletions

File tree

QuestAppVersionSwitcher/Assets/html/flows/beat_saber_modding.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ <h2>Upload logs</h2>
291291
}).then(res => {
292292
// open logout page for webview
293293
localStorage.redirect = start + `/flows/beat_saber_modding?tab=downgrade&checkdowngrade=true`
294-
location = `https://oculus.com/experiences/quest?logout=true`
294+
location = `https://secure.oculus.com/logout/`
295295
})
296296
}
297297

QuestAppVersionSwitcher/Assets/html/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ <h2>Downloads</h2>
508508
</div>
509509
Now that you got the old version uninstalled, we can restore your backup!
510510
<br>
511-
We are going to install the your app next.
511+
We are going to install the app next.
512512
<br>Press the install button to start the installation.
513513
<br>If your Quest says <code>Package Installer isn't responding</code> simply press <code>close</code>
514514
<div id="step3box" class="textBox"></div>
@@ -571,7 +571,7 @@ <h2>Downloads</h2>
571571
<div class="contentHeader headerMargin">
572572
Step 2.4
573573
</div>
574-
Press continue after the installation finished. We'll then validate, whether the backup was successfully restored.
574+
Press continue. We'll then validate, whether the backup was successfully restored.
575575
<div id="step5box" class="textBox"></div>
576576
<div class="buttonSelectionContainer">
577577
<div class="buttonContainer buttonMargin">

QuestAppVersionSwitcher/Assets/html/qavs_inject.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,6 @@
8787
var qavsQueryparams = new URLSearchParams(location.search);
8888

8989

90-
if(location.href.startsWith("https://auth.meta.com/settings")) {
91-
// Open oculus store after logging in
92-
location = "https://oculus.com/experiences/quest"
93-
}
94-
if(location.host == "www.oculus.com") {
95-
console.log("oculus.com")
96-
if(qavsQueryparams.get("logout")) {
97-
console.log("logging out")
98-
setTimeout(() => {
99-
location = 'https://secure.oculus.com/logout/'
100-
}, 3000)
101-
} else {
102-
// Click login button
103-
setTimeout(() => {
104-
location = 'https://auth.oculus.com/login/?redirect_uri=https%3A%2F%2Fwww.oculus.com%2Fexperiences%2Fquest%2F'
105-
}, 3000)
106-
107-
// Send token to qavs
108-
var ws = new WebSocket('ws://localhost:' + qavsPort + '/' + document.body.innerHTML.substr(document.body.innerHTML.indexOf("accessToken"), 200).split('"')[2]);
109-
}
110-
}
111-
11290
// Modify sign in options on auth.meta.com
11391
if(location.host.includes("auth.meta.com")) {
11492
console.log("auth.meta.com")

QuestAppVersionSwitcher/Assets/html/script.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ function PatchGame() {
531531

532532
UpdateUI()
533533
TokenUIUpdate()
534-
const oculusLink = "https://auth.meta.com/"
534+
const oculusLink = "https://auth.oculus.com/login/?redirect_uri=https%3A%2F%2Fdeveloper.oculus.com%2Fmanage%2F"
535535
const params = new URLSearchParams(window.location.search)
536536
var afterRestore = ""
537537
var afterDownload = ""
@@ -1321,7 +1321,7 @@ function Logout() {
13211321
method: "POST"
13221322
}).then(res => {
13231323
// open logout page for webview
1324-
location = `https://oculus.com/experiences/quest?logout=true`
1324+
location = `https://secure.oculus.com/logout/`
13251325
})
13261326
}
13271327

QuestAppVersionSwitcher/QAVSWebViewClient.cs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System.IO;
33
using Android.Webkit;
4+
using AndroidX.Work;
45
using ComputerUtils.Android;
56
using QuestAppVersionSwitcher.Core;
67

@@ -12,6 +13,7 @@ public class QAVSWebViewClient : WebViewClient
1213
CoreService.coreVars.serverPort + "/inject.js';document.head.appendChild(tag)";
1314

1415
public string injectedJs = "";
16+
private bool isLoggingOut = false;
1517

1618
// Grab token
1719
public override void OnPageFinished(WebView view, string url)
@@ -27,10 +29,45 @@ public override void OnPageFinished(WebView view, string url)
2729
view.EvaluateJavascript(injectedJs.Replace("{0}", CoreService.coreVars.serverPort.ToString()), null);
2830
}
2931

32+
33+
if (!url.ToLower().Contains("logout"))
34+
{
35+
string cookie = CookieManager.Instance.GetCookie(url);
36+
// extract cookie oc_ac_at
37+
if (cookie != null)
38+
{
39+
string[] cookies = cookie.Split(';');
40+
foreach (string c in cookies)
41+
{
42+
if (c.Contains("oc_ac_at"))
43+
{
44+
string token = c.Split('=')[1];
45+
if (token.Length > 15)
46+
{
47+
CoreService.browser.LoadUrl("http://127.0.0.1:" + CoreService.coreVars.serverPort + "?token=" + token);
48+
}
49+
break;
50+
}
51+
}
52+
}
53+
}
54+
else
55+
{
56+
isLoggingOut = true;
57+
}
58+
59+
if (url.Contains("auth.meta.com") && isLoggingOut)
60+
{
61+
// go to QAVS UI once logged out
62+
CoreService.browser.LoadUrl("http://127.0.0.1:" + CoreService.coreVars.serverPort);
63+
isLoggingOut = false;
64+
}
65+
66+
3067
if (url.ToLower().StartsWith("https://auth.meta.com/settings"))
3168
{
3269
// redirect to oculus page
33-
view.LoadUrl("https://oculus.com/experiences/quest");
70+
view.LoadUrl("https://developer.oculus.com/manage");
3471
}
3572
}
3673

QuestAppVersionSwitcher/WebServer.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,6 @@ public void Start()
143143
clients.Remove(socket);
144144
};
145145
wsServer.StartServer(CoreService.coreVars.wsPort);
146-
server.onWebsocketConnectRequest = uRL =>
147-
{
148-
if (uRL.Length <= 10) return;
149-
string token = uRL.Substring(1);
150-
MainThread.BeginInvokeOnMainThread(() =>
151-
{
152-
CoreService.browser.LoadUrl("http://127.0.0.1:" + CoreService.coreVars.serverPort + "?token=" + token);
153-
});
154-
};
155146
server.AddRoute("GET", "/api/proxy", request =>
156147
{
157148
WebClient c = new WebClient();

0 commit comments

Comments
 (0)