Skip to content

simple server/webapp api (https://mcrealms.herokuapp.com/) for the Microsoft oauth flow integration with the minecraft realms/auth api and node wrapper for https://pc.realms.minecraft.net

License

Notifications You must be signed in to change notification settings

revzim/mc-realms

Repository files navigation

  • heroku hosted web server and api example to ease authentication flow with newly migrated microsoft accounts
  • info about the web app
  • (down - free azure membership ended)

simple server/web app and node wrapper for the Minecraft Realms API

API ENDPOINTS

  • all mc-realms api requests besides / require a token query param
  • optional query params:
    • version: minecraft version (current default: 1.17.1)
  • /
    • GET request => registering & granting auth to azure app
    • redirects to /token?code=<CODE>
      • <CODE> will be your one time use generated code by the microsoft oauth flow process
  • /profile?token=<TOKEN>
    • GET request => user account profile
  • /worlds?token=<TOKEN>
    • GET request => user account realms
  • /userdata?token=<TOKEN>
    • GET request => user account profile & realm information
  • <TOKEN> is your minecraft access token you either parsed or received earlier throughout the oauth flow process
  • written in a day, so expect changes.

IMPORTANT:

mojang => microsoft account migrations

  • mojang has been in the process of migrating user accounts to microsoft accounts
  • previous versions of this api return an error/warning detailing the account migration
  • migrating an account to microsoft will introduce the end user to the microsoft oauth flow
    1. oauth code
    2. oauth code => oauth token
    3. oauth token => xbl auth
    4. xbl auth => xsts auth
    5. xsts auth => minecraft auth
    6. minecraft auth => check ownership of game
    7. user authenticated and can now get profile/realm/server info
  • the microsoft oauth flow is documented on the wiki
  • due to the microsoft oauth flow differing from the mojang oauth flow, the authentication process pipeline is broken once migrating accounts
  • I hosted a web server/app api connected to a free azure application that makes it easy for anyone to authenticate with the new microsoft oauth flow
  • once the auth process is completed, you will receieve your access_token, which can be used within the mc-realms api ecosystem or the minecraft realms api ecosystem
    1. sign in with microsoft
    2. give permission to mc-realms azure application
    3. if the login/authentication process is successful you will receive a payload with an access_token, which can now be used within the minecraft ecosystem to retreive account information
    • the access token has a lifetime of 86400 seconds (24 hours/1 earth day)
    • after that, you can refresh or issue yourself a new token
    • occasionally, pc.realms.minecraft.net will return a Retry again later response, this is typical and it just means to try again later
    1. end user can now use mc-realms endpoints with their token
    2. API ENDPOINTS

host your own

IMPORTANT

-due account migration to microsoft based authentication, any authentication with migrated accounts requires use of an azure application client id & secret

-hosting your own mc-realms server/web app requires some knowledge of microsoft azure. prior to anything below you should have an application set up and ready to be configured. you can follow instructions on how to create an azure application here

  • git clone https://github.com/revzim/mc-realms
  • yarn or npm i
  • copy .env.default to .env
  • PORT => the port you will host your server/webapp from
  • CLIENT_ID => your azure application client id
  • CLIENT_SECRET => your azure application client secret
  • REDIRECT_URI => a valid redirect uri for your azure application
    • default is http://localhost/token to emulate how the mc-realms web app works
    • within the context of this server, unless you are altering any of the source code, redirect uris should follow the paradigm host/token to work ootb
  • run dev: yarn dev || npm run dev
  • build: yarn build || npm run build => yarn start || npm run start
  • head to http://localhost
  • API ENDPOINTS

MORE DETAILS:

-for educational purposes only

-very early stages development server/api source code

-development began 2021-10-05 and have no idea of the future of the project

  • source code prior to microsoft account migration moved to /mojang

author