Skip to content

Setting Cookies on request #2286

@FuckingToasters

Description

@FuckingToasters

Hello, i can't find the correct way to set all needed cookies. This is the cookie tab from the response:
grafik

Now i want to use client and tried a lot of different things to set the cookies but none of them solved it. Here is the current code:

    data1 = {"deviceId": "", "userName": username, "password": password}
    cookies = httpx.Cookies()

    resp1 = httpx.post("https://api.fedex.com/user/v4/login", headers=headers, json=data1, follow_redirects=True)

    try: 
        with httpx.Client(proxies=proxy_auth if proxy_type != "" else None) as client: 
            client.cookies.set(name="FedEx-Secure-Login-Cookie", value="true", domain="https://fedex.com/secure-login/")
            client.cookies.set(name="_abck", value=resp1.cookies.get("_abck"), domain="https://edex.com/secure-login/")
            client.cookies.set(name="expires", value=resp1.cookies.get("expires"), domain="https://edex.com/secure-login/")
            resp2 = client.post("https://api.fedex.com/user/v4/login", headers=headers, json=data1, follow_redirects=True)
    
    except httpx.ProxyError: 
        with httpx.Client(proxies=None) as client: resp2 = client.post("https://api.fedex.com/user/v4/login", headers=headers, json=data1, follow_redirects=True)
    
    set_cookie = f"siteDC=edc; xacc=DE; fdx_cbid=30207856121656437730110340266011; fdx_locale=de_DE; fdx_redirect=de-de; cc_path=de; isTablet=false; isMobile=false; isWireless=false; aemserver=PROD-P-dotcom-p0008480.prod.cloud.fedex.com; _abck={resp1.cookies.get('_abck')}; ADRUM=s=1656441915426&r=https%3A%2F%2Fwww.fedex.com%2Fsecure-login%2F%3F-1854754532; s_invisit=true; gpv_pageName=fedex/apps/wlgn/login-credentials; mboxEdgeCluster=37"
    headers["Cookie"] = set_cookie
    print(resp1.cookies)
    print(cookies.set(name="FedEx-Secure-Login-Cookie", value="true"))
    print(cookies.set(name="_abck", value=resp1.cookies.get("_abck"), domain="https://edex.com/secure-login/"))
    print(cookies.get("FedEx-Secure-Login-Cookie"))
    print("-----------------------------------------------------")
    print(resp2.text)

    # print(resp2.json()["errors"][0]["code"])

The error i'm seening every time:

<Cookies[<Cookie _abck=9D653246B520E9AEF2535C75C976823E~-1~YAAQFuZlX7wNOo6BAQAAoPWrtghDDCi7c261ywX9SyxVtDo91R0pgBQnSUW6flrVg8KOrg5fkuJaFeczho1eCwDtPKn3eOsOarydFUK4F6UE00/fUEITlzn0kTf/Jiuny1j7+jULCNUR5QetwGseKivnipCbwQbpKZePNd1aURkM0PrjMOjaJjgGDl6SU6hDhWaBiRYNboIlBSz1bX60dKKZfUFTjXMAfmARuk1kVTYGt4bsIt/Fs7TEAFB20qhwj/rU5qEjkdrAMLoJ8uMSL5N5i8zi6t36qevc9U3G8+iG9d8fjvIh8HHJ5MyIwjy1qsJcn+8YYwTZnaQtK+paNhyly0CnCQ62UdsaS33hBEuhKqY9//Qu7yNrVi0=~-1~-1~-1 for .fedex.com />, <Cookie bm_sz=118A0D88115C5E503300B088C49F1D00~YAAQFuZlX70NOo6BAQAAoPWrthBks2eyNDxhigIZtL7o/c+a0YDQOAGUre1B4x2Z0tnW5r8SFalRRg0cs05N1umnjBjImwpcA2Z6/vHU96P96RTT+01ZCVzypgGKelWNlQENBpkt8vQH1HTVjR8Nh+PL9Pu+mtB5cEn/WGcoIKIrLEUfRzHachJ9VZ66EZ/9JMWCIPAPWkXxPwwiZEn5jHfJsvnCi8qMHw8xl4M7y9KR42JzK0HDk85CyB82hHrMdTk1k6Xu+7db7LG+O3/XXrGQG6alX2Nrgukz+0zNjqf4Fg==~4273478~4404549 for .fedex.com />]>
None
None
true
-----------------------------------------------------
<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access "http&#58;&#47;&#47;api&#46;fedex&#46;com&#47;user&#47;v4&#47;login" on this server.<P>
Reference&#32;&#35;18&#46;16e6655f&#46;1656627131&#46;2679623b
</BODY>
</HTML>

This error is cookie releated because when i manually enter the correct cookie in the request header, everything works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions