def get_query_hash(uri, method, query_params=None): # see # https://developer.atlassian.com/static/connect/docs/latest/concepts/understanding-jwt.html#qsh uri = uri.rstrip("/") method = method.upper() if query_params is None: query_params = {} sorted_query = [] for k, v in sorted(query_params.items()): # don't include jwt query param if k != "jwt": if isinstance(v, list): param_val = ",".join([percent_encode(val) for val in v]) else: param_val = percent_encode(v) sorted_query.append("{}={}".format(percent_encode(k), param_val)) query_string = "{}&{}&{}".format(method, uri, "&".join(sorted_query)) return hashlib.sha256(query_string.encode("utf8")).hexdigest()
def get_query_hash(uri, method, query_params=None): # see # https://developer.atlassian.com/static/connect/docs/latest/concepts/understanding-jwt.html#qsh uri = uri.rstrip('/') method = method.upper() if query_params is None: query_params = {} sorted_query = [] for k, v in sorted(query_params.items()): # don't include jwt query param if k != 'jwt': if isinstance(v, list): param_val = [percent_encode(val) for val in v].join(',') else: param_val = percent_encode(v) sorted_query.append('%s=%s' % (percent_encode(k), param_val)) query_string = '%s&%s&%s' % (method, uri, '&'.join(sorted_query)) return hashlib.sha256(query_string.encode('utf8')).hexdigest()
def get_query_hash(uri, method, query_params=None): # see # https://developer.atlassian.com/static/connect/docs/latest/concepts/understanding-jwt.html#qsh uri = uri.rstrip('/') method = method.upper() if query_params is None: query_params = {} sorted_query = [] for k, v in sorted(query_params.items()): # don't include jwt query param if k != 'jwt': if isinstance(v, list): param_val = ','.join([percent_encode(val) for val in v]) else: param_val = percent_encode(v) sorted_query.append('%s=%s' % (percent_encode(k), param_val)) query_string = '%s&%s&%s' % (method, uri, '&'.join(sorted_query)) return hashlib.sha256(query_string.encode('utf8')).hexdigest()