Skip to content

Instantly share code, notes, and snippets.

@bazbt3
Last active October 28, 2017 13:15
Show Gist options
  • Save bazbt3/010f3989ecd6ac37cef02d9ad3bb3a20 to your computer and use it in GitHub Desktop.
Save bazbt3/010f3989ecd6ac37cef02d9ad3bb3a20 to your computer and use it in GitHub Desktop.
Simple Python code failing with the 'secrettoken' variable
# Pasting the secret access token works at `pnutpy.api.add_authorization_token(secrettoken)`. HOWEVER I want to remove my access token from this code to ***allow sharing.***
import pnutpy
import console
tokenfile = open("secrettoken.txt", "r")
secrettoken = tokenfile.read()
# print secrettoken
pnutpy.api.add_authorization_token(secrettoken)
# Create a post
posttext = raw_input("posttext: ")
post, meta = pnutpy.api.create_post(data={'text':posttext})
@bazbt3
Copy link
Author

bazbt3 commented Oct 28, 2017

I know a little Python 3, can't figure out much of Python 2. I believe the code is valid Python 2 but it fails to work thus:

  1. Fails to run with Python 3.5 interpreter.
  2. Substituting the text of the access token works but using the variable name fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment