Created
December 20, 2019 16:59
-
-
Save NickelMattera/b2034ffaa1eefb1782ed9f54ff0588c9 to your computer and use it in GitHub Desktop.
OAuth with the Switch Web Applet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <switch.h> | |
using namespace std; | |
int main() { | |
const char * GITHUB_AUTH_URL = "https://github.com/login/oauth/authorize?client_id=%PUT_CLIENT_ID_HERE%&scope=public_repo,read:packages,repo:status&allow_signup=false"; | |
const char * CALLBACK_URL = "https://oauth.teamatlasnx.com/oauth/"; | |
consoleInit(NULL); | |
WebCommonConfig web; | |
webPageCreate(&web, GITHUB_AUTH_URL); | |
webConfigSetCallbackUrl(&web, CALLBACK_URL); | |
WebCommonReply reply; | |
webConfigShow(&web, &reply); | |
WebExitReason exitReason; | |
webReplyGetExitReason(&reply, &exitReason); | |
if (exitReason == WebExitReason_LastUrl) { | |
char lastUrl[1000] = ""; | |
webReplyGetLastUrl(&reply, lastUrl, 1000, NULL); | |
cout << lastUrl << "\n"; | |
} else { | |
cout << "Error: Web Applet didn't exit due to callback URL.\n"; | |
} | |
while (appletMainLoop()) { | |
hidScanInput(); | |
if (hidKeysDown(CONTROLLER_P1_AUTO)) | |
break; | |
consoleUpdate(NULL); | |
} | |
consoleExit(NULL); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment