Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate an Epic login into the app (but not directly) #614

Closed
ghost opened this issue Aug 16, 2021 · 13 comments · Fixed by #798
Closed

Integrate an Epic login into the app (but not directly) #614

ghost opened this issue Aug 16, 2021 · 13 comments · Fixed by #798
Labels
feature-request New feature needs to be implemented.

Comments

@ghost
Copy link

ghost commented Aug 16, 2021

Is your feature request related to a problem? Please describe.
The current SID implementation is confusing.
Describe the solution you'd like
An epic login, but outside Heroic (so open epic login in a browser) and then redirect to heroic with our protocol (heroic://login/SID) automatically. So the user only needs to login and that's it!

Describe alternatives you've considered
None

Additional context
See #42

@flavioislima flavioislima added the feature-request New feature needs to be implemented. label Aug 18, 2021
@ArjixWasTaken
Copy link

ArjixWasTaken commented Aug 19, 2021

It's pretty simple.
When the user clicks to login you will open the auth page on the browser and launch a local server that will wait for the redirect to send the data over.
Once the data is received in-app you can close the local server and that's all.

There is no need for a custom protocol.

@ghost
Copy link
Author

ghost commented Aug 19, 2021

It's pretty simple.
When the user clicks to login you will open the auth page on the browser and launch a local server that will wait for the redirect to send the data over.
Once the data is received in-app you can close the local server and that's all.

There is no need for a custom protocol.

launching a local server is a security risk (see https://www.electronjs.org/docs/latest/tutorial/security). There already is a protocol in heroic, called 'heroic://' hence it makes sense to use it.

We could also use this electron.js method called 'protcol.interceptHttpProtocol'

@arielj
Copy link
Collaborator

arielj commented Nov 4, 2021

I was looking into this. I tried adding a heroic://... url for the redirectUrl parameter of the login url but epic does not allow custom urls there

image

unless I'm missing something

I'm also not sure I understand the idea of the local server either

what about opening the login url but in a webview inside the app? then we can use the webview events (https://www.electronjs.org/docs/latest/api/webview-tag/#event-did-stop-loading for example) to know when it finished doing something and then we inspect the content to look for the sid? though it will require the user to login in the webview and if you use something like login with google you then need to login with google too, which is not ideal

@derrod
Copy link

derrod commented Nov 4, 2021

The only real way of doing this (since you need the credentials of the "real" launcher) is to embed the login. Doing so requires a few things to be added to the window object so the website thinks it's being opened within the launcher.

See what I did for legendary for reference: https://github.com/derrod/legendary/blob/master/legendary/utils/webview_login.py

@ghost
Copy link
Author

ghost commented Nov 4, 2021

I was looking into this. I tried adding a heroic://... url for the redirectUrl parameter of the login url but epic does not allow custom urls there

image

unless I'm missing something

I'm also not sure I understand the idea of the local server either

what about opening the login url but in a webview inside the app? then we can use the webview events (https://www.electronjs.org/docs/latest/api/webview-tag/#event-did-stop-loading for example) to know when it finished doing something and then we inspect the content to look for the sid? though it will require the user to login in the webview and if you use something like login with google you then need to login with google too, which is not ideal

When we have the website ready we can have a redirect URL.

@derrod
Copy link

derrod commented Nov 4, 2021

No you can't. Because any URL that's not epic's own domain won't work.

@ghost

This comment has been minimized.

@derrod
Copy link

derrod commented Nov 16, 2021

@no95typem

This comment has been minimized.

@ghost

This comment has been minimized.

@derrod

This comment has been minimized.

@flavioislima
Copy link
Member

flavioislima commented Dec 19, 2021

what about opening the login url but in a webview inside the app? then we can use the webview events (https://www.electronjs.org/docs/latest/api/webview-tag/#event-did-stop-loading for example) to know when it finished doing something and then we inspect the content to look for the sid? though it will require the user to login in the webview and if you use something like login with google you then need to login with google too, which is not ideal

I'm trying this approach and it worked fine once, but now it doesn't.
I mean, I load the webview, login on epic website, then it shows the Object with the SID.
Then I used the webview function selectAll to select the content, then it was selecting the whole text, then I copied it, then get the content from clipboard and parse it to be a JSON.
with that, I get the sid and call legendary auth with it.
It worked fine once, but now, for some F@#$ reason, the selectAll function is selecting everything since Heroic, not only the content inside the webview.

Then, I tried to use the find function to pass a Regex to select everything inside the {}, but this function only accepts strings 🤦🏽

so, I'll start from scratch on that and try to use a different approach.

@flavioislima
Copy link
Member

Good news!
I noticed that the problem was that the webview was losing focus after redirecting so webview.focus() did the trick 🎉

@flavioislima flavioislima linked a pull request Dec 19, 2021 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature needs to be implemented.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants