Home

Awesome

Nintendo Switch Online Rich Presence

Display your Nintendo Switch game status on Discord!

This README will be split into two sections:

Credits

This project uses the Nintendo Switch Online Mobile App API.
I'd like to thank:

<h1 id = 'quick'>Quickstart Guide</h1>

Download the app from the latest release and run!
Once ran, the app will ask for you to log into your Nintendo account on a web browser. There is no malicious code with intent to steal your information, but it's best to review the code for yourself.

  1. Open Discord and NSO-RPC
  1. Log in to your Nintendo account when prompted

  2. Right click on 'Select this account' and press 'Copy Link'

link

  1. Paste the link in the pop-up's form and click 'Log In'

  2. Control your rich presence from the app and system tray icon

display

FAQ

If none of the below Qs and As help with your problem, feel free to file an issue. Alternatively, you can join the NSO-RPC Discord server for a better back-and-forth method of communication with me!

Q: Do you need a Nintendo Switch Online subscription to use this app?
A: No, you do not. This app works whether or not you have access to online services. You will, however, need to link your Nintendo account to your user profile on your Switch.

Q: My computer says that this app might have a virus! Does it?
A: No. Your computer is saying that because it's a foreign executable file downloaded from the internet, so you should always be cautious about it. If you'd like, you can build your own exe.

Q: You're not stealing my account/data, are you?
A: Not me, personally. You'll have to ask frozenpandaman (s2s) and @NexusMine (flapg). They are responsible for some of the authentication steps. This project now uses imink API to provide for some authentication steps. Read more here, and be weary of any possible theft.

<ul><li><details> <summary><b><i>What if I don't want to use imink?</i></b></summary>

A: It is possible to tweak the code and remove the API calls, then instead only use temporary tokens you have provided for authorization headers. However, this is tedious and completely up to the user to perform- as the tokens expire after 7200 seconds (two hours) and are only obtainable through methods such as mitmproxy

</details></li></ul>

Q: Do I need Discord open on my PC to use this application?
A: Yes. You need the desktop application open in order for the app to update your Discord status.

Q: Can I use the Discord website/run this on a Chromebook?
A: No. The website does not have a method of updating your Rich Presence from games on your computer, so NSO-RPC will not work with it.

Q: I can't get the program to run, what's wrong with it?!
A: Delete the NSO-RPC folder in your Documents folder. If that doesn't work, you should run the cli.py program and get the error data, then make an issue on Github and I'll investigate it.

Q: I can't link my Nintendo Account. What do I do?
A: Refer to the question above.

Q: My status is displaying as offline and won't change!
A: First, make sure that you have a secondary account linked and have selected your main account from the friends list. If you've done that and you're still having problems with an offline status, make sure that both settings in your user profile (play activity and display online status settings) are set to "all friends".

Q: I keep getting Error Code 9407; what should I do?
A: You're going to have to link your account with a real Nintendo Switch at least once in order to use the API and add your main account as a friend. (See #73)

I am not liable for any sort of rate limiting Nintendo may hammer upon your network

<h1 id = 'depth'>In-depth guide</h1> <h2 id = 'building'>Building</h2>

For Windows, run

cd .\NSO-RPC\scripts
.\build.bat

For MacOS, run

cd ./NSO-RPC/scripts
chmod +x build.sh
./build.sh

For Linux (Ubuntu), run

cd ./NSO-RPC/scripts
chmod +x install.sh
./install.sh

*(Make sure you have python3 and pip installed)

<h2 id = 'understanding'>Understanding</h2>

This is going to be a detailed explanation on everything that I do here and exactly what is going on. If you're into that sort of stuff, keep reading. If not, feel free to skim and get a general idea of the procedures.
I try my best to be detailed and give a proper comprehensive guide, but I'm not perfect. Feel free to make an issue if you feel anything in particular should be updated!

I'm going to be explaining my cli.py as it isn't as complicated as the GUI (app.py).
(You can follow along with the guide here and here)

As of 8abf86c, this guide is outdated in regards to the APIs used.

<details> <summary><h3>1. Getting your <code>session_token</code></h3></summary>

First things first, we need to get access to your Nintendo account. What we need to get is your session_token, which is a unique identifier that confirms to Nintendo servers you are you. This is the code that gets your session_token.
cli.py:

path = os.path.expanduser('~/Documents/NSO-RPC/private.txt')
  if not os.path.isfile(path):
      session = Session()
      session_token = session.run(*session.login(session.inputManually))
  else:
      with open(path, 'r') as file:
          session_token = json.loads(file.read())['session_token']

First, it checks if you already have a session_token saved. If so, then it just uses that.
If not, then it will create a Session() object and call Session().login() (passing Session().inputManually) Session().run().
That's all fine and dandy, but what does it do behind the Session().login() and Session.run() functions?
Glad you asked.

</details> <details> <summary><h3>2. Connecting to Discord</h3></summary>

We create a Discord() object and pass the newly obtained session_token (and user_lang) to it. This does not involve sending your session_token to Discord.
cli.py:

client = Discord(session_token, user_lang)
client.background()
</details> <details> <summary><h3>3. Nintendo's API</h3></summary>

Oh boy.

Alright, this gets complicated, but I'll try and cover it all quickly.
*For code snippets, see api/__init__.py

</details> <details> <summary><h3>4. The <code>f</code> token</h3></summary>

This hurts me. This is the reason why we have to call third-party APIs in order to 'login' to Nintendo. It essentially just verifies that you are connecting from a real Nintendo Switch Online Mobile app (ineffectively, obviously).
Since what's required to generate it is potentially incriminating, we have to generate it using third-party APIs (namely s2s and flapg).

</details>