parser.add_argument('-a', '--app-id', default="https://app.example/oauth/code",
help="application id (default %(default)s)")
parser.add_argument('-i', '--issuer', default="https://self-issued.me",
help="id_token issuer (default %(default)s)")
parser.add_argument('-K', '--key-id', help="JWK kid (default %(default)s)")
parser.add_argument('-A', '--app-auth', help="app authorizations URI (use multiple times)", action='append')
parser.add_argument('-t', '--token-only', action='store_true',
help="output the bare access token instead of the full JSON response")
parser.add_argument('-d', '--debug', action='store_true')
parser.add_argument('uri', help="URI to access")
args = parser.parse_args()
is_self_issued = args.issuer == "https://self-issued.me"
privateKey = rsa.PrivateKey.load_pkcs1(open(args.private_key, "rb").read())
def b64u_encode(s):
return base64.urlsafe_b64encode(s).rstrip('=')
def compact_json(obj):
return json.dumps(obj, indent=None, separators=(',', ':'))
def urlencode(query):
rv = []
for k, v in query.iteritems():
if v:
rv.append('%s=%s' % (urllib.quote_plus(str(k)), urllib.quote(str(v), '')))
return '&'.join(rv)