phoenixlzx / mochimochi

Simple Asset Management
MIT License
7 stars 0 forks source link

Any plans on updating this to fab? #2

Closed delebash closed 4 days ago

delebash commented 5 days ago

Nice work on this. I made an electron version of an unreal vault organizer and used a sniffer to get the unreal vault token but your login process is much better. I was looking at making this work for fab but I am running into some issues. So I ran fiddler sniffer to see the new asset urls. It looks like https://www.fab.com/e/accounts/your account id/ue/library?count=100 works. I used postman and added the auth key generated from your program. Your auth method still works. I got the expected data for assets in the ue vault.

"cursors": {
        "next": "ZW1wPTM0JmZhYj0zMyZ1ZXM9MzM="
    },
    "results": [
        {
            "assetId": "8c09b41c22f5472ebdf9b12a5d36a72e",
            "assetNamespace": "89efe5924d3d467c839449ab6ab52e7f",
            "categories": [
                {
                    "id": "0a4f7590-4376-400b-a6e4-c7a658cbab47",
                    "name": "Humans"
                }
            ],
            "description": "Paragon: Kallari",
            "distributionMethod": "ASSET_PACK",
            "images": [
                {
                    "md5": null,
                    "type": "Featured",
                    "url": "https://media.fab.com/image_previews/gallery_images/2b20d84c-1d20-4228-b9c1-604d2a468e08/f3204a85-df23-4d1f-a8d6-ffabbe19e19e.jpg",
                    "width": "640",
                    "height": "349",
                    "uploadedDate": "2024-10-17T08:59:44.005557Z"
                }
            ],...............

and so on.

I am having problems making the above get request in code. When making the get node-fetch request to https://www.fab.com/e/accounts/your account id/ue/library?count=100 with all the necessary headers I keep getting a 403 error. I even tried the request using python just to make sure it was not a node-fetch issue.

Example python

import requests
import json
url = "https://www.fab.com/e/accounts/myaccount/ue/library?count=100"
headers = {
    "Host": "www.fab.com",
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate",
    "Accept-Language": "en",
    "X-Epic-Correlation-ID": "UE4-5ce167234cb050824fe597bcf7544a27-CBCB5328462F7829A0A50FB30DC6B694-359D3F5847980E23B0E601A0285EFDD6",
    "User-Agent": "UELauncher/17.0.1-37584233+++Portal+Release-Live Windows/10.0.22631.1.768.64bit",
    "Authorization": "Bearer eg1~.......",
    "Connection": "keep-alive",
    "Content-Length": "0"
}
response = requests.request("GET", url, headers=headers)

print(response.status_code)

I have tested with 3 different api test programs and they all successfully completed the get request. Postman, HttpToolkit, and WebMaestro. I grabbed the exact headers that Postman was sending and used them in my code. I can't figure out why the api testing programs work and my code doesn't. Maybe some type of cloudflare protection but if the api testers work than we should be able to replicate that from code. Of course I could just be missing something simple, so if you have time to look at getting this working with fab that would be awesome. Cheers!

delebash commented 4 days ago

I think the problem is from the refer using localhost. I changed to using axios while I was troubleshooting the problem but that did not fix it. I ran a node test app and the request still failed with 403. However, when I did the same request from the main.js in an Electron project it worked fine. Here is my complete axios request just fyi.

import axios from 'axios'
import * as https from "node:https";

let axiosRequest = {
    url: 'https://www.fab.com/e/accounts/accountid/ue/library?count=100',
    method: 'GET',
    headers: {
        'Host': 'www.fab.com',
        'User-Agent': 'UELauncher/17.0.2-37848679+++Portal+Release-Live Windows/10.0.22631.1.768.64bit',
        'Authorization': 'Bearer eg.....'
    },
    httpAgent: new https.Agent({ rejectUnauthorized: false, noDelay: true, path: null }),
    signal: new AbortController().signal,
    timeout: 0,
    maxRedirects: 21,
    withCredentials: false
}

let response = await axios(axiosRequest)
console.log('response', response.data)