Home Technical Talk

Quixel Megascans API - 401 log in problem

polycounter lvl 14
Offline / Send Message
.morph3us polycounter lvl 14
Before the Quixel Store closes, I would like to download my models.
I do not want to do this manually, so I want to utilize the websocket API:

I cobbled together this initial script just to see how far I'd get:
const axios = require('axios');

const APP_ID = 'copied from quixel website';
const APP_KEY = 'copied from quixel website';
const USERNAME = 'tried all of the 4 options from below';

async function authenticate() {
    try {
        const response = await axios.post(AUTH_URL, {
            secret: APP_KEY
        }, {
            auth: {
                username: USERNAME,
                password: ''
            },
            headers: {
                'Content-Type': 'application/json'
            }
        });

        const { token, refreshToken } = response.data;
        console.log("Authentication Token:", token);
        console.log("Refresh Token:", refreshToken);

        return token;
    } catch (error) {
        if (error.response) {
            console.error('Error Response:', error.response.data);
            console.error('Error Status:', error.response.status);
            console.error('Error Headers:', error.response.headers);
        } else if (error.request) {
            console.error('Error Request:', error.request);
        } else {
            console.error('Error Message:', error.message);
        }
        console.error('Error Config:', error.config);
    }
}

authenticate();
Unfortunately I get a 401 error running the javascript file via npm.

When running this directly in the Chrome Devtools while having the quixel site open:
console.log(document.cookie)
actually retrieves the token, so the API has to be working.

Which means that my credentials have to be wrong.
As app key and app id are easily retrievable from the megascans page, I fear I do not get the username correctly.
I registered to Quixel even before it merged with Epic, so I have 4 different potential options for the username(as seen in the attached images):
- my epicgames account has two options: a "user-randomnumber", which is the display name, or the mail I use for the Epicgames Store, "MyNewMail@web.de"

- my quixel account has "MyOldMail@web.de"

- the unrealengine account shows the "user-randomnumber"

- the unrealengine forums shows "FirstletterOfMyNameFullLastName"


But although I tried all combinations, I can not find why it is not working at all.
I am a bit bummed out to fail at even logging in...
Is there someone who can help me spot the obvious? This cant be so hard, can it?

Is this even the correct spot to post? I think there are some Quixel members floating around here, no?
Is there a better place, perhaps the Unreal Engine forums? I have not seen a "Quixel Support" anywhere...

Replies

  • .morph3us
    Offline / Send Message
    .morph3us polycounter lvl 14
    Okay, got it to work now. Its a myriad of different things that went wrong. If anybody is interested, I will elaborate, but as this post did not seize any traction, I dont think there is so much interest to demand a lengthy writeup.
  • Eric Chadwick
    Thanks for the post tho. But do you really "own" those assets? Curious if the TOS has a way for them to refuse access retroactively, even if you initially paid for something. Good ol' SAAS. 
  • WAUthethird
    Okay, got it to work now. Its a myriad of different things that went wrong. If anybody is interested, I will elaborate, but as this post did not seize any traction, I dont think there is so much interest to demand a lengthy writeup.
    I would be very much interested in how you got it to work! I gave up and just used my browser's user token, which for some reason works just fine with the documented API. Currently writing a script to download every asset on the site.
    I would also be especially curious to know if you got refresh tokens working -- the method for a token refresh isn't documented anywhere and I haven't yet been able to catch my browser refreshing its token.
  • .morph3us
    Offline / Send Message
    .morph3us polycounter lvl 14
    Thanks for the post tho. But do you really "own" those assets? Curious if the TOS has a way for them to refuse access retroactively, even if you initially paid for something. Good ol' SAAS. 
    As far as I understood and remember the announcement, the permission is granted indefinetly. The only thing I worry about is if I'll be able to access the models after the move to fab.com. Thats why I think its good to backup the models before its too late.

    I would be very much interested in how you got it to work! I gave up and just used my browser's user token, which for some reason works just fine with the documented API. Currently writing a script to download every asset on the site.
    I would also be especially curious to know if you got refresh tokens working -- the method for a token refresh isn't documented anywhere and I haven't yet been able to catch my browser refreshing its token.
    I am happy to help as far as I can: 
    1.) The login combination was what I referred to as "MyOldMail@web.de", which is the name displayed in the Quixel account on the upper left quadrant, and the Quixel Account login. This could be different from your Epicgames password (at least it was for me).
    You can log out, go to the login page and on the lower half, where you can log into you quixel account (not the epic account), you can reset your password to be sure what you need to input.
    I think its working in the browser console for you, because you are already logged in and you get the token from the cookie?
    (I really dont know what I am talking about here!)
    2.) I have been bothering a dude from Quixel's support for about a week now, I am currently awaiting his response to exactly the same question about the refresh tokens. I think the approach I will take, if I can not get them to work, is that I will just request a new token before each download.

    P.S.: I am also already in talks with Quixel about the EULA.
    https://www.unrealengine.com/en-US/eula/content
    As far as I can see sharing this script is not legal up to this point.
    See "
    c. General Restrictions".
    But I will keep you all updated with the response
  • .morph3us
    Offline / Send Message
    .morph3us polycounter lvl 14
    I would be very much interested in how you got it to work! I gave up and just used my browser's user token, which for some reason works just fine with the documented API. Currently writing a script to download every asset on the site.
    I would also be especially curious to know if you got refresh tokens working -- the method for a token refresh isn't documented anywhere and I haven't yet been able to catch my browser refreshing its token.
    I got an answer today along the lines of: The refresh token API has never been implemented correctly. make a call to the api, if it fails your token is not valid anymore and you need to request a fresh new token.
Sign In or Register to comment.