From cbcdb9f33152e10b73df0b2efdb50d3fb9e0e972 Mon Sep 17 00:00:00 2001 From: Matthew Connelly Date: Wed, 13 Jun 2018 17:58:20 +0100 Subject: [PATCH] slight amount of change lol --- main.py | 7 +++++-- uJIRA.py | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 76c7c5d..34ef83d 100644 --- a/main.py +++ b/main.py @@ -7,9 +7,12 @@ init_sample.PrintHWInfo(hw) # Main app import uJIRA +from machine import Pin, TouchPad jcloud = uJIRA.client('tradeprint.atlassian.net') auth = { - 'method': 'basic-auth', + 'method': 'basic-auth', #Only basic-auth is supported for now, oauth is a headache 'username': '', 'password': '', -} \ No newline at end of file +} + +jcloud.login(auth) diff --git a/uJIRA.py b/uJIRA.py index c646450..0a8e408 100644 --- a/uJIRA.py +++ b/uJIRA.py @@ -1,6 +1,7 @@ import ussl import urequests import usocket +import ubinascii class client: def __init__(self, jira_server): @@ -8,4 +9,7 @@ class client: def login(self, params): self.method = params['method'] - self.username = params['username'] \ No newline at end of file + if self.method != 'basic-auth': + raise ValueError("Authentication method %s not supported by this library." % self.method) + self.basic_auth = "%s:%s" % (params['username'], params['password']) + self.basic_auth = ubinascii.b2a_base64(("%s:%s" % (params['username'], params['password'])).encode()).decode()[:-1] \ No newline at end of file