1

I am encountering this error when I try to export a string of bytes as an environment variable. I have read this question and was able to set the variable using bash script, but when I try to add the variable to the Run configurations in pycharm I get this error;

Error when trying to access the application

Here are values I tried with for Environment variables field;

SECRET_KEY='\x06IP\xd0\x89\x8fU\x0b\xee\x85:\xe8x\xa6\xa6,\x88\xc6YU%&\xee\xcao\xca\xa0\xba\xbdo\xf2?'

SECRET_KEY=\x06IP\xd0\x89\x8fU\x0b\xee\x85:\xe8x\xa6\xa6,\x88\xc6YU%&\xee\xcao\xca\xa0\xba\xbdo\xf2?

SECRET_KEY=b'\x06IP\xd0\x89\x8fU\x0b\xee\x85:\xe8x\xa6\xa6,\x88\xc6YU%&\xee\xcao\xca\xa0\xba\xbdo\xf2?'

SECRET_KEY=$'\x06IP\xd0\x89\x8fU\x0b\xee\x85:\xe8x\xa6\xa6,\x88\xc6YU%&\xee\xcao\xca\xa0\xba\xbdo\xf2?'

None of them worked. Any help will be much appreciated.

jeff kim
  • 21
  • 1
  • 2
  • 4

1 Answers1

1

The error indicates that the secret key should a string rather than bytes. You can base64 encode the bytes to get a string.

For example from a Linux terminal:

python -c 'import os;print(os.urandom(32))' | base64

Then use the generated encoded string as the SECRET_KEY

Eddy
  • 76
  • 1
  • 7