https://linen.dev logo
#ask-community-for-troubleshooting
Title
# ask-community-for-troubleshooting
d

Daniel Eduardo Portugal Revilla

01/21/2022, 1:31 PM
Hello! I am trying to create a HTTP connector for consume a servicesnow API i am following the tutorial Speedrun but T do not know where put the credentials for the API
Copy code
{
  "type": "LOG",
  "log": {
    "level": "FATAL",
    "message": "HttpStream.__init__() got an unexpected keyword argument 'auth'\nTraceback (most recent call last):\n  File \"/Users/daniel_edu/Projects/PERSONAL/airbyte/airbyte-integrations/connectors/source-servicesnow-api/main.py\", line 13, in <module>\n    launch(source, sys.argv[1:])\n  File \"/Users/daniel_edu/Projects/PERSONAL/airbyte/airbyte-integrations/connectors/source-servicesnow-api/.env/lib/python3.10/site-packages/airbyte_cdk/entrypoint.py\", line 127, in launch\n    for message in source_entrypoint.run(parsed_args):\n  File \"/Users/daniel_edu/Projects/PERSONAL/airbyte/airbyte-integrations/connectors/source-servicesnow-api/.env/lib/python3.10/site-packages/airbyte_cdk/entrypoint.py\", line 118, in run\n    for message in generator:\n  File \"/Users/daniel_edu/Projects/PERSONAL/airbyte/airbyte-integrations/connectors/source-servicesnow-api/.env/lib/python3.10/site-packages/airbyte_cdk/sources/abstract_source.py\", line 92, in read\n    stream_instances = {s.name: s for s in self.streams(config)}\n  File \"/Users/daniel_edu/Projects/PERSONAL/airbyte/airbyte-integrations/connectors/source-servicesnow-api/source_servicesnow_api/source.py\", line 55, in streams\n    return [ServicesnowApi(auth=(config[\"psswrd\"], config[\"psswrd\"]), user=config[\"user\"], psswrd=config[\"psswrd\"])]\n  File \"/Users/daniel_edu/Projects/PERSONAL/airbyte/airbyte-integrations/connectors/source-servicesnow-api/source_servicesnow_api/source.py\", line 67, in __init__\n    super().__init__(**kwargs)\nTypeError: HttpStream.__init__() got an unexpected keyword argument 'auth'"
  }
}
I was trying this script
Copy code
def streams(self, config: Mapping[str, Any]) -> List[Stream]:
        """
        TODO: Replace the streams below with your own streams.

        :param config: A Mapping of the user input configuration as defined in the connector spec.
        """
        # TODO remove the authenticator if not required.
        auth = TokenAuthenticator(token="api_key")  # Oauth2Authenticator is also available if you need oauth support
        return [ServicesnowApi(authenticator=(config["psswrd"], config["psswrd"]))]
👀 1
1
a

Augustin Lafanechere (Airbyte)

01/21/2022, 2:00 PM
Hi @Daniel Eduardo Portugal Revilla, according to servicenow documentation I can see they support 3 types of authentication, which one do you want to pick?
• _*API Key*_: A unique code provided by the REST API to identify the calling application or user.
• _*Basic Authentication*_: A user name and password combination used to authenticate to the REST API.
• _*OAuth 2.0*_: An authentication provider provides a secret and uses that information to grant access to a resource. OAuth is beyond the scope of this training module
d

Daniel Eduardo Portugal Revilla

01/21/2022, 2:07 PM
on pure python, this script work for me
Copy code
# Do the HTTP request
response = requests.get(url_sn, auth=(username, password))

# Check for HTTP codes other than 200
if response.status_code != 200:
    print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:', response.json())
    exit()

data = response.json()
print(data)
Basic Authentication
a

Augustin Lafanechere (Airbyte)

01/21/2022, 2:19 PM
Ok, so you need to use request's HTTPBasicAuth as the authenticator. Feel free to check this connector code as an example.
d

Daniel Eduardo Portugal Revilla

01/21/2022, 2:59 PM
thanks! it works!
Copy code
def streams(self, config: Mapping[str, Any]) -> List[Stream]:
        auth = HTTPBasicAuth(config["user"], config["psswrd"])  # Oauth2Authenticator is also available if you need oauth support
        return [ServicesnowApi(authenticator=auth)]
6 Views