Unable to create access tokens for user migration (invalid_client)

Hello. I recently transferred an app from my dev account to a different one. I'm trying to follow these instructions to generate transfer IDs, and am stuck on Step 1 (creating an access token).

I keep getting {'error': 'invalid_client'}. Here's the python script I'm using to generate the access token:

TEAM_ID = "..."
KEY_ID = "..."
KEY_FILE = "key.p8"
CLIENT_ID = "com.myapp.bundle"

def get_access_token() -> str:
    client_secret = get_client_secret()
    print(f"client secret: {client_secret}")

    url = "https://appleid.apple.com/auth/token"
    req_headers = {"Content-Type": "application/x-www-form-urlencoded"}
    data = {
        "grant_type": "client_credentials",
        "scope": "user.migration",
        "client_id": CLIENT_ID,
        "client_secret": client_secret,
    }
    response = requests.post(url, headers=req_headers, data=data)
    json = response.json()

    return json["access_token"]

def get_client_secret() -> str:
    payload = {
        "iss": TEAM_ID,
        "iat": int(time.time()),
        "exp": int(time.time() + 86400 * 7),  # 7 days
        "aud": "https://appleid.apple.com",
        "sub": CLIENT_ID,
    }

    key = open(KEY_FILE, "r").read()
    print(f"Key: {key}")

    headers = {"alg": "ES256", "kid": KEY_ID}
    return jwt.encode(payload, key, algorithm="ES256", headers=headers)


print(get_access_token())

The app was transferred about 2 weeks ago, so well within the 60 day period. And the script actually briefly got an access token for about 30 minutes yesterday, but is no longer working.

Any ideas? Thanks in advance.

Answered by sou17 in 802580022

I was able to solve this. In my case, the error was that the new dev account had "grouped" the apple sign in with a new bundle ID. Undoing that fixed it.

I was able to solve this. In my case, the error was that the new dev account had "grouped" the apple sign in with a new bundle ID. Undoing that fixed it.

Unable to create access tokens for user migration (invalid_client)
 
 
Q