Giter Club home page Giter Club logo

revzim / mc-realms Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 2.0 76 KB

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

Home Page: https://mcrealms.herokuapp.com/

License: MIT License

JavaScript 0.66% TypeScript 99.34%
minecraft node nodejs realms minecraft-realms minecraft-server minecraft-realm node-wrapper mc-realms microsoft

mc-realms's Introduction

  • 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

mc-realms's People

Contributors

revzim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mc-realms's Issues

How would I use this?

First of all I am not the very good a node. When I run it in the cmd it says invalid credentials. Where would I add credentials?

Outdated API

It looks like this package cannot currently obtian the IP and port of a realm. The endpoint for that on the realms API seems to have moved to /worlds/v1/$ID/join/pc. This seems like a relatively simple fix of refactoring some of the API interaction. I'd be happy to make a PR if I find the time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.