Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Basic Auth Authorization to Lever Hiring Connector #16572

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@
"editor.codeActionsOnSave": {
"source.fixAll.stylelint": true
}
}
},
"python.analysis.extraPaths": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand it may improve your local vscode setup, is it okay to undo this change? Thanks.

"./airbyte-cdk/python"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@

from airbyte_cdk.sources import AbstractSource
from airbyte_cdk.sources.streams import Stream
from airbyte_cdk.sources.streams.http.auth import Oauth2Authenticator
from airbyte_cdk.sources.streams.http.auth import BasicHttpAuthenticator, Oauth2Authenticator

from .streams import Applications, Interviews, Notes, Offers, Opportunities, Referrals, Users


def _auth_from_config(config):
return Oauth2Authenticator(
client_id=config["credentials"]["client_id"],
client_secret=config["credentials"]["client_secret"],
refresh_token=config["credentials"]["refresh_token"],
token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token",
)

if config and config["credemtials"] and 'api_key' in config["credentials"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a typo, credemtials?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it okay to add a check on config["credentials"]["auth_type"], when the auth_type is Api Key

return BasicHttpAuthenticator(username=config["credentials"]["api_key"], auth_method="Basic")
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def setup_responses():
responses.add(
responses.POST, "https://sandbox-lever.auth0.com/oauth/token", json={"access_token": "fake_access_token", "expires_in": 3600}
)

Similar to the unit test for check_connection above, can you add one for the basic auth? Thanks.

return Oauth2Authenticator(
client_id=config["credentials"]["client_id"],
client_secret=config["credentials"]["client_secret"],
refresh_token=config["credentials"]["refresh_token"],
token_refresh_endpoint=f"{SourceLeverHiring.URL_MAP_ACCORDING_ENVIRONMENT[config['environment']]['login']}oauth/token",
)


class SourceLeverHiring(AbstractSource):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@
"airbyte_secret": true
}
}
},
{
"type": "object",
"title": "Authenticate via Lever (Api Key)",
"required": ["api_key"],
"properties": {
"auth_type": {
"type": "string",
"const": "Api Key",
"enum": ["Api Key"],
"default": "Api Key",
"order": 0
},
"api_key": {
Copy link
Contributor

@YiyangLi YiyangLi Sep 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add an order for the property api_key?

"title": "Api key",
"type": "string",
"description": "The Api Key of your Lever Hiring developer application."
}
}
}
]
},
Expand Down