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

NameError: name 'requests' is not defined #163

Closed
gaglimax opened this issue Jun 11, 2020 · 2 comments
Closed

NameError: name 'requests' is not defined #163

gaglimax opened this issue Jun 11, 2020 · 2 comments
Milestone

Comments

@gaglimax
Copy link

NameError: name 'requests' is not defined

Request Type

Bug

Work Environment

Question Answer
OS version (server) Docker
OS version (client) Docker
TheHive4py version / git hash ed7c637

Problem Description

In file thehive4py/auth.py, you need to import requests. Else, an error occured

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/thehive4py/auth.py", line 24, in __call__
    req.headers['Authorization'] = requests.auth._basic_auth_str(self.username, self.password)
NameError: name 'requests' is not defined

Steps to Reproduce

  1. Execute the fonction

Possible Solutions

import requests

@nadouani
Copy link
Contributor

Hello, how did you install thehive4py? The error means you don't have the requests dependency

@gaglimax
Copy link
Author

It is install via pip inside Docker.

In my script, I have the requests dependency. The issue comes from file : thehive4py/auth.py

In line 24, the script is using requests, but the module is not imported at the beggining of the file.
You should add import requests before the line from requests.auth import AuthBase.

I have just created a pull requests : #168.

@nadouani nadouani added this to the 1.7.2 milestone Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants