slight amount of change lol

This commit is contained in:
Matthew Connelly 2018-06-13 17:58:20 +01:00
parent 9be6ca2e3b
commit cbcdb9f331
2 changed files with 10 additions and 3 deletions

View File

@ -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': '',
}
}
jcloud.login(auth)

View File

@ -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']
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]