# 'pyarrow.\_flight.FlightUnauthenticatedError'\> : Flight returned unauthenticated error

**URL:** <https://community.dremio.com/t/pyarrow-flight-flightunauthenticatederror-flight-returned-unauthenticated-error/12952>\
**Category:** Uncategorized\
**Created:** [April 17, 2025, 7:50am UTC](https://community.dremio.com/t/pyarrow-flight-flightunauthenticatederror-flight-returned-unauthenticated-error/12952 "2025-04-17T07:50:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snasef](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@snasef](https://community.dremio.com/u/snasef)\
**Post date:** [April 17, 2025, 7:50am UTC](https://community.dremio.com/t/pyarrow-flight-flightunauthenticatederror-flight-returned-unauthenticated-error/12952/1 "2025-04-17T07:50:59Z")

</div>

I’m running Dremio community edition on docker , trying to connect using sample code snippet below but always got unauthenticated error

`> <class 'pyarrow._flight.FlightUnauthenticatedError'> : Flight returned unauthenticated error, with message:`

My code snippet

class BasicAuthClientAuthHandler(flight.ClientAuthHandler):  
def **init** (self, username, password):  
super(). **init** ()  
self.username = username  
self.password = password

```
def authenticate(self, outgoing, incoming):
    logger.debug("Sending basic auth credentials")
    outgoing.write(self.username.encode('utf-8'))
    outgoing.write(self.password.encode('utf-8'))
    #outgoing.close()
    logger.debug("Waiting for auth response")
    incoming.read() # blocks until server accepts or rejects

def get_token(self):
    return b"" # Optional: implement if server returns a token

```

class DremioClient:  
def **init** (self, host, port, username, password):  
self.location = f"grpc+tcp://{host}:{port}"  
logger.info(f"Connecting to Dremio at {self.location}")  
self.client = flight.FlightClient(self.location)  
self.\_auth(username, password)

```
def _auth(self, username, password):
    logger.info(f"Authenticating as {username}")
    auth_handler = BasicAuthClientAuthHandler(username, password)
    self.client.authenticate(auth_handler)
    logger.info("Authentication successful")

```

Any advise how to fix this code

---

<div class="post-metadata">

**Author:** ![Arseniy\_Tsypushkin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/arseniy_tsypushkin/32/5955_2.png) [@Arseniy\_Tsypushkin](https://community.dremio.com/u/Arseniy_Tsypushkin)\
**Post date:** [April 21, 2025, 11:37am UTC](https://community.dremio.com/t/pyarrow-flight-flightunauthenticatederror-flight-returned-unauthenticated-error/12952/2 "2025-04-21T11:37:32Z")

</div>

Hey @snasef !

I don’t know where you took this code snippet.

If you want to start using pyarrow client with Dremio, you could check out our public github repo with Python Arrow client example over here - [Link to client examples](https://github.com/dremio-hub/arrow-flight-client-examples/tree/main/python)

There is a readme with all the details on how to connect to different versions of Dremio. Plus, you could double-check your code with an existing example from this repo.
