MixV2 / EpicResearch

Research about Epic Games' non-documented API
350 stars 84 forks source link

Unable to get auth code with Authorization Code #14

Closed esfesTheKing closed 4 years ago

esfesTheKing commented 4 years ago

I was looking around the web and found this repo which can improve my programs exacute time. I am trying for the past 2 days to get an auth code with Authorization Code. I read the the instructions about 50 times and was still unable to get the auth code. My question is can you please give an example in some programming language, for example python?

MixV2 commented 4 years ago

What issue arises when trying to get an authorisation code exactly?

esfesTheKing commented 4 years ago

I was able to figure out how to get it in the end. Thank you for your research. I will post a solution later. I have another question the lookup of accounts by id, how do i look for more than 1 account at a time, and how do i get the name of players whom account is set to private?

MixV2 commented 4 years ago

Glad you got it working!

For multiple account ID lookups, check out this guide: e.g. if you wanted to lookup:

... the URL for the request would look like: https://account-public-service-prod.ol.epicgames.com/account/api/public/account?accountId=4735ce9132924caf8a5b17789b40f79c&accountId=3d9c055689d341d9b88a917630a6bdb9&accountId=3bebf5cdb9434fcfb455ef4807ae099c

What do you mean by accounts that are set to private? To my knowledge, you should be able to get the account ID from a display name no matter what.

esfesTheKing commented 4 years ago

I am getting the display name from an account id, in my testing some of the accounts are set to private. When the account is set to private you are unable to get a diplay name. Thanks for your replay and for your hard work

esfesTheKing commented 4 years ago

And what is the difference between a 'displayName' and an 'externalDisplayName'

MixV2 commented 4 years ago

I'm unfamiliar with what you mean by accounts being "set to private".

I believe that the displayName is the display name of the Epic account, where the externalDisplayName is the display name of an external account (e.g. an XBOX account, PlayStation account, etc..).

esfesTheKing commented 4 years ago

i got an error once where i didnt find any displayName, so i went to fortnite tracker to see if there was a problem and it said something like can find an account that was set to private in game. but now i can recreate the issue any longer. I want to thank you once again for creating this repo and i would like to know if i can help in any way?

esfesTheKing commented 4 years ago

image

my solution, written in python.

The code it self:

import requests

code = '''
    The code you got from this link https://www.epicgames.com/id/api/redirect?clientId=ec684b8c687f479fadea3cb2ad83f5c6&responseType=code
    {"redirectUrl":"https://accounts.epicgames.com/fnauth?code=THE CODE YOU FOUND HERE","sid":null}
    '''

def tokenObtainer(code):
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': 'basic ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ=',
    }

    body = {
        'grant_type': 'authorization_code',
        'code': code
    }

    return requests.post('https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token', headers=headers, data=body).json()['access_token']

access_token = tokenObtainer(code)
MixV2 commented 4 years ago

Nice!

Feel free to create a PR if you find anything that isn't already documented.

esfesTheKing commented 4 years ago

Is there a way to get a permanent auth token?

MixV2 commented 4 years ago

You could use something like device auth to create a set of credentials that can be used to continuously generate an access token.

esfesTheKing commented 4 years ago

So there isnt a way to get a permanent access token?

MixV2 commented 4 years ago

No, access tokens expire after 8 hours.

youngchief-btw commented 4 years ago

*For security reasons