-2

I've taken a look at many other "Questions that may already have your answer", but didn't come across any that hit directly on the issue I'm running into.

Here's my Python 2 snippet:

api_access_token = base64.b64encode('%s:' % api_access_token_setup)

I am getting the following error:

TypeError: 'str' does not support the buffer interface

Any chance there's a quick fix for solving the error being prompted.

2
  • 2
    You need a bytes object, not str. Commented Aug 17, 2017 at 16:33
  • 1
    Pro tip when searching: add the function that caused the exception. Google had the duplicates in seconds when I searched for the exception and 64encode. Commented Aug 17, 2017 at 16:34

1 Answer 1

1

As the error suggests, you need to pass bytes, not str type to b64encode. Try encoding your string:

api_access_token = base64.b64encode(('%s:' % api_access_token_setup).encode())
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.