yihong0618 / IdeoImageCreator

About High quality image generation by ideogram. Reverse engineered API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception: Error response <Response [403]>

yuvraj108c opened this issue · comments

The pip package is not working as expected.

Export IDEO_COOKIE='xxxxx'.
Export IDEO_AUTH_TOKEN='xxxxx' (found after Bearer in the HEADERS of the requests).
Export IDEO_USER_ID='xxxxx'.

and use python -m way to try

ok it works. Thanks!

It stopped working :(
Getting 403

It stopped working :( Getting 403

you should export them every time or you can add it to ~/.bashrc
please google or chatgpt it about how to

It stopped working :( Getting 403

you should export them every time or you can add it to ~/.bashrc please google or chatgpt it about how to

I know. The env variables are set properly. I even updated the cookies/tokens
it stopped working for me for some reason

The token is only valid for an hour. How to update automatically?

The token is only valid for an hour. How to update automatically?

not it exists a long time

I used Claude 2 at claude.ai to write some code to update the token automatically, works great but the code is nasty and not PR ready.

This isn't all of it but here's the main sauce:
Key is some value I got from F12 in the browser. seems to be the same every time.

def login(key):
    url = "https://securetoken.googleapis.com/v1/token"
    headers = {
        "authority": "securetoken.googleapis.com",
        "Content-Type": "application/x-www-form-urlencoded",
        "origin": "https://ideogram.ai",
        "referer": "https://ideogram.ai/",
        "user-agent": "Mozilla/5.0",
    }
    form_data = {
        "grant_type": "refresh_token",
        "refresh_token": load_refresh_token()
    }
    try:
        response = requests.post(url, headers=headers, data=form_data, params={'key': key})
        response.raise_for_status()
        data = response.json()
        refresh_token = data.get("refresh_token")
        access_token = data.get("access_token")
        save_refresh_token(refresh_token)
        print(f'Access token: {access_token}, Refresh token: {refresh_token}')
        return access_token
    except requests.RequestException as e:
        print(f"An error occurred during token login: {e}")
        raise

I also save/write the token to a txt file that my calling script works with. I can't share that here.