Language examples in auth process


#1

Would be great to add different languages to the example auth process here

I’ve created a python one https://gist.github.com/stevepeak/2939349d21cc68024d09583a8529d07d

Cheers!


#2

I’ve created a node version (well two actually, one with async/await support and one without): https://gist.github.com/jcready/6dff3db44fe9e3465d39c2d4f5295478


#3

@jcready during my testing I came into an issue with the 600 second limit. It works, but not all the time. I would recommend updating to 500 where I have not seen any failures yet.

GitHub has not posted a number to my knowledge, so 500s may be wrong… idk :open_hands:


#4

Thanks for taking the time to share those examples @stevepeak and @jcready! :thumbsup:

We don’t have plans to add additional language examples to the docs just yet, but I’ll keep an eye on this thread to see what languages folks are interested in as we consider the request. Feel free to keep additional language requests and examples coming.

during my testing I came into an issue with the 600 second limit. It works, but not all the time. I would recommend updating to 500 where I have not seen any failures yet.

GitHub has not posted a number to my knowledge

The JWT tokens have a 10 minute expiration window. We’ll be updating the docs to include this information, and we’ll post back here with a link once those are live.


#5

@stevepeak Thanks for the code example! I’m trying to get this to work in Python 3 and it’s not working. Have you tried to convert it to 3 before?

If you just run it as is in Python 3 (obviously fixing the print statements) it gives the error:

    headers = {'Accept': 'application/vnd.github.machine-man-preview+json', 'Authorization': 'Bearer '+token}
TypeError: must be str, not bytes

So if I try to convert it to a string like so:

headers = {'Accept': 'application/vnd.github.machine-man-preview+json', 'Authorization': 'Bearer '+str(token)}

It gives an invalid credential error:

401 {'message': 'Invalid credentials', 'documentation_url': 'https://developer.github.com/v3'}

#6

Fixed my problem, You must decode token instead of just converting to a string.

So str(token) should be: token.decode("utf-8")