Forum Discussion

TJE's avatar
TJE
New Contributor
3 months ago
Solved

Successful authentication locally, 403 when executed on server.

When using the one password python library, I get the error
"authentication error: http error: unexpected http status: 403 Forbidden" when running my code on a server or google colab, but it works fine when I run it on my laptop, even though the same credentials are used.  Any idea about what might be going wrong?

Here is the (slightly modified) code snippet:

from onepassword.client import Client

import asyncio
import os

async def get_mfa_code():
    ONEPASSWORD_TOKEN = os.environ['ONEPASSWORD_TOKEN']
    vault_cred = os.environ['vault_cred']
    client = await Client.authenticate(auth=ONEPASSWORD_TOKEN, integration_name="My Integration Name", integration_version="v1.0.0")

    # Retrieve credentials from 1Password
    username = await client.secrets.resolve(f"{vault_cred}/username")
    password = await client.secrets.resolve(f"{vault_cred}/password")
    mfa_code = await client.secrets.resolve(f"{vault_cred}/mfa_code?attribute=otp")
    return username, password, mfa_code
asyncio.run(get_mfa_code())
import nest_asyncio
nest_asyncio.apply()
asyncio.run(get_mfa_code())

 

  • Resolved this;  our firewall settings were blocking all cloud providers.

1 Reply

  • TJE's avatar
    TJE
    New Contributor

    Resolved this;  our firewall settings were blocking all cloud providers.