Event Timeline
Comment Actions
Tried this in python but for some reason (come to think of it, most probably because of session issue, it did not work...)
#!/usr/bin/env python3 # documentation: # https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization import click import logging import requests import sys logger = logging.getLogger(__name__) @click.command() @click.option('--login') @click.option('--password') def main(login, password): auth = (login, password) url = 'https://api.github.com' # authenticate query r0 = requests.get(url, auth=auth) if not r0.ok: logger.error('Fail to authenticate, stopping. Reason: %s', r0.content) sys.exit(1) url = 'https://api.github.com/authorizations/' r = requests.post(url, auth=auth, json={ 'scope': ['public_repo'], 'note': 'Allow listing github repositories', }) if r.ok: data = r.json() token = data['token'] logger.info('token: %s', token) logger.debug('\n#### Full output: %s\n####', data) else: logger.error('Failed to create token. Reason: %s', r.content) if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) logging.getLogger('urllib3').setLevel(logging.WARN) main()