| 762 | } |
| 763 | |
| 764 | static std::string getHtml(const QString &redirect) |
| 765 | { |
| 766 | QString html = R"( |
| 767 | <html> |
| 768 | <head> |
| 769 | <title>Advanced scene switcher</title> |
| 770 | </head> |
| 771 | <body> |
| 772 | <div id="output">Please click this link to continue if not automatically redirected</div> |
| 773 | <p><a href="%1">Login with Twitch</a></a></p> |
| 774 | <script type="text/javascript"> |
| 775 | if (document.location.hash && document.location.hash != '') { |
| 776 | var parsedHash = new URLSearchParams(window.location.hash.slice(1)); |
| 777 | if (parsedHash.get('access_token')) { |
| 778 | window.location.replace(`http://localhost:%1/token?access_token=${parsedHash.get('access_token')}&state=${parsedHash.get('state')}`); |
| 779 | output.textContent = 'It is safe to close this window'; |
| 780 | } |
| 781 | } else { |
| 782 | window.location.replace('%2'); |
| 783 | } |
| 784 | </script> |
| 785 | </body> |
| 786 | </html>)"; |
| 787 | |
| 788 | return html.arg(QString::number(tokenGrabberPort), redirect) |
| 789 | .toStdString(); |
| 790 | } |
| 791 | |
| 792 | void TwitchTokenSettingsDialog::RequestToken() |
| 793 | { |