Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create example repository #55

Open
SpraxDev opened this issue May 14, 2020 · 6 comments
Open

Create example repository #55

SpraxDev opened this issue May 14, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@SpraxDev
Copy link
Member

SpraxDev commented May 14, 2020

Create an extra repository containing examples in different languages/enviroments

Examples:

  • Node.js
  • PHP
  • Java
@SpraxDev SpraxDev added enhancement New feature or request help wanted Extra attention is needed labels May 14, 2020
@SpraxDev SpraxDev changed the title npm package Create an official npm package May 14, 2020
@SpraxDev SpraxDev changed the title Create an official npm package Create example repository Sep 15, 2020
@SpraxDev SpraxDev self-assigned this Sep 15, 2020
@SpraxDev SpraxDev removed the help wanted Extra attention is needed label Sep 15, 2020
@Paul2708
Copy link

Paul2708 commented Nov 2, 2020

Hey, I could implement an example in Java. However, I need additional information about the general process and the protocol used to communicate.

@SpraxDev
Copy link
Member Author

SpraxDev commented Nov 3, 2020

That would be great! I've populated the Wiki with more detailed information: https://github.com/Mc-Auth-com/Mc-Auth/wiki.

Reach back to me if you've got some questions or if I forgot to mention something.

@SpraxDev SpraxDev added the help wanted Extra attention is needed label Nov 3, 2020
@Paul2708
Copy link

Paul2708 commented Nov 6, 2020

Hey, sorry for asking such a dumb question about OAuth 2.0 / HTTP in general because I haven't worked with it before.

Consider the following example:
Alice and Bob want to log into their SuperFancyApplication account. They choose Login via MC-Auth.
Both will be redirected to MC-Auth, join the server, fill in the code, hit Authorize (or Confirm, etc.) and will be redirected to redirect_uri?code=XXX.
Now, I have to match which code refers to whom, however, I will get two different HTTP requests. Therefore, I don't know which request belongs to Alice or Bob.

What am I missing?

@SpraxDev
Copy link
Member Author

SpraxDev commented Nov 7, 2020

You've got two options for that:

  1. You exchange the code for a token and together with the token, a 'data' field is sent (I believe that's actually agains OAuth specs - Added it as TODO Don't send 'data' when exchanging for a token #103). It contains the Minecraft uuid. If you've specified &scope=profile it will contain the whole profile sent by the Mojang API.
  2. You use the state parameter to identify individual requests.

Normally, you'd have some kind of session management on SuperFancyApplication and don't care about who the code belongs to. You'd just assume that the code and the user-agent was not tempered (that's what the state argument is for) and assume that the token you've exchanged for the code belongs to that user.

That's how the server should respond when you successfully exchanged a code for an token (with scope=profile):

{
  "access_token": "<The access_token>",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "profile",
  "state": "<The same value provided for `state` in step 2>",
  "data": {
    "uuid": "407b28ede7bd451693d93361fecb7889",
    "profile": {
      "id": "407b28ede7bd451693d93361fecb7889",
      "name": "Sprax2013",
      "properties": [
        {
          "name": "textures",
          "value": "<Base64 string>",
          "signature": "<Base64 string; signed data using Yggdrasil's private key>"
        }
      ]
    }
  }
}

@Paul2708
Copy link

Paul2708 commented Nov 7, 2020

Alright, I got it!
Any preferences for the example? Spring, Javalin, general wrapper class, link between Discord and MC user, ...

@SpraxDev
Copy link
Member Author

SpraxDev commented Nov 7, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Development

No branches or pull requests

2 participants