clubby789 / htb-api

PyHackTheBox is an unofficial Python library to interact with the Hack The Box API.
https://pypi.org/project/PyHackTheBox/
46 stars 8 forks source link

Implementing Authentication/Authorization by API key of the HTB user #58

Closed D3vil0p3r closed 2 years ago

D3vil0p3r commented 2 years ago

I see that currently, for authenticating it is required to add username and password (hardcoded).

Is it possible to add also authentication by providing the API key of the user?

clubby789 commented 2 years ago

Yes

from hackthebox import HTBClient
client = HTBClient(app_token='token')

Note this uses V2's 'app tokens', and NOT the 'api token' present in the V1 settings page.

D3vil0p3r commented 2 years ago

Yes

from hackthebox import HTBClient
client = HTBClient(app_token='token')

Note this uses V2's 'app tokens', and NOT the 'api token' present in the V1 settings page.

Thanks for the answer @clubby789 In the user settings there are to tokens image

The Account Identifier that is written to be used for being identified by HTB public API and the second one App Token. So, you mean the V1 is the Account Identifier while the V2 is this App Token?

clubby789 commented 2 years ago

The account identifier is only used on the Discord server. The V1 API token is only available + useful on the V1 version of the site

D3vil0p3r commented 2 years ago

The account identifier is only used on the Discord server. The V1 API token is only available + useful on the V1 version of the site

Ok. So I guess we must use App Tokens if we want to authenticate on HTBClient(app_token='token')