Hi, I want to ask, how we get bearer in our Airbyt...
# replication-ask-ai
a
Hi, I want to ask, how we get bearer in our Airbyte API? in this case I'm using Airbyte OSS
k
To authenticate requests with a bearer token in Airbyte Open Source, you can use the BearerAuthenticator object. This object injects a bearer token as a request header in the form
Authorization: Bearer <token>
. The token is typically obtained from your API's settings or during the OAuth process. Here's an example of how you can use it:
Copy code
yaml api_token: "{{ config['api_key'] }}"
or
Copy code
yaml api_token: "{{ config['token'] }}"
In these examples,
api_key
and
token
are placeholders for the actual key names you have in your configuration. Replace them with the actual key names. You can also set custom HTTP headers to send to Airbyte's API with the
octavia
command:
Copy code
bash octavia --api-http-header Authorization Bearer my-secret-token list connectors sources
Or use a custom YAML file to declare the HTTP headers to send to the API:
Copy code
yaml headers:    Authorization: Bearer my-secret-token    User-Agent: octavia-cli/0.0.0
Environment variable expansion is available in this YAML file:
Copy code
yaml headers:    Authorization: Bearer ${MY_API_TOKEN}
Please note that options based headers are overriding file based headers if a header is declared in both. For more details, you can refer to the [Airbyte CLI documentation](https://docs.airbyte.com/cli-documentation) and the [YAML Reference](https://docs.airbyte.com/connector-development/config-based/understanding-the-yaml-file/reference) in the Airbyte documentation.
a
I mean how to generate it, in example if username is
airbyte
and password is
password
and we get bearer auth
t
using python -
Copy code
import base64

# Concatenate username and password with a colon and encode in Base64
credentials = base64.b64encode(f'{username}:{password}'.encode('utf-8')).decode('utf-8')

headers = {
    'Authorization': f'Basic {credentials}'
}
✅ 1
a
Yes, I was get this solution before, thank you for answering @Tamunopriye George
✅ 1