code
string | signature
string | docstring
string | loss_without_docstring
float64 | loss_with_docstring
float64 | factor
float64 |
---|---|---|---|---|---|
docs = []
for filename in filenames:
with open(filename, 'r') as f:
docs.append(f.read())
return "\n\n".join(docs) | def get_long_docs(*filenames) | Build rst description from a set of files. | 2.080303 | 2.123548 | 0.979635 |
strings = re.split('}\s*(?={)', raw_text)
# put back the stripped character
json_strings = [string + '}' for string in strings[:-1]]
# the last one doesn't need to be modified
json_strings.append(strings[-1])
return json_strings | def detect_json_strings(raw_text) | Use regex with lookaround to spot the boundaries between JSON objects.
Unfortunately, it has to match *something*, so at least one character
must be removed and replaced. | 5.685255 | 5.033446 | 1.129496 |
# serialize instances of SchemaNode before parsing
if isinstance(schema, SchemaNode):
schema = schema.to_schema()
for subschema in self._get_subschemas(schema):
# delegate to SchemaType object
schema_generator = self._get_generator_for_schema(subschema)
schema_generator.add_schema(subschema)
# return self for easy method chaining
return self | def add_schema(self, schema) | Merges in an existing schema.
arguments:
* `schema` (required - `dict` or `SchemaNode`):
an existing JSON Schema to merge. | 6.153952 | 6.054441 | 1.016436 |
# delegate to SchemaType object
schema_generator = self._get_generator_for_object(obj)
schema_generator.add_object(obj)
# return self for easy method chaining
return self | def add_object(self, obj) | Modify the schema to accommodate an object.
arguments:
* `obj` (required - `dict`):
a JSON object to use in generating the schema. | 8.31982 | 7.738153 | 1.075169 |
types = set()
generated_schemas = []
for schema_generator in self._schema_generators:
generated_schema = schema_generator.to_schema()
if len(generated_schema) == 1 and 'type' in generated_schema:
types.add(generated_schema['type'])
else:
generated_schemas.append(generated_schema)
if types:
if len(types) == 1:
(types,) = types
else:
types = sorted(types)
generated_schemas = [{'type': types}] + generated_schemas
if len(generated_schemas) == 1:
(result_schema,) = generated_schemas
elif generated_schemas:
result_schema = {'anyOf': generated_schemas}
else:
result_schema = {}
return result_schema | def to_schema(self) | Convert the current schema to a `dict`. | 2.238881 | 2.121782 | 1.055189 |
app.config.setdefault('SSLIFY_AGE', self.defaults['age'])
app.config.setdefault('SSLIFY_SUBDOMAINS', self.defaults['subdomains'])
app.config.setdefault('SSLIFY_PERMANENT', self.defaults['permanent'])
app.config.setdefault('SSLIFY_SKIPS', self.defaults['skips'])
app.before_request(self.redirect_to_ssl)
app.after_request(self.set_hsts_header) | def init_app(self, app) | Configures the specified Flask app to enforce SSL. | 2.582293 | 2.460335 | 1.04957 |
hsts_policy = 'max-age={0}'.format(self.hsts_age)
if self.hsts_include_subdomains:
hsts_policy += '; includeSubDomains'
return hsts_policy | def hsts_header(self) | Returns the proper HSTS policy. | 2.811572 | 2.227423 | 1.262253 |
# Should we skip?
if self.skip_list and isinstance(self.skip_list, list):
for skip in self.skip_list:
if request.path.startswith('/{0}'.format(skip)):
return True
return False | def skip(self) | Checks the skip list. | 4.05054 | 3.690133 | 1.097668 |
# Should we redirect?
criteria = [
request.is_secure,
current_app.debug,
current_app.testing,
request.headers.get('X-Forwarded-Proto', 'http') == 'https'
]
if not any(criteria) and not self.skip:
if request.url.startswith('http://'):
url = request.url.replace('http://', 'https://', 1)
code = 302
if self.permanent:
code = 301
r = redirect(url, code=code)
return r | def redirect_to_ssl(self) | Redirect incoming requests to HTTPS. | 2.875527 | 2.861785 | 1.004802 |
color = self.get_color()
color2 = (hue, color[1], color[2], color[3])
try:
if rapid:
self.fire_and_forget(LightSetColor, {"color": color2, "duration": duration}, num_repeats=1)
else:
self.req_with_ack(LightSetColor, {"color": color2, "duration": duration})
except WorkflowException as e:
raise | def set_hue(self, hue, duration=0, rapid=False) | hue to set
duration in ms | 4.046612 | 4.175503 | 0.969132 |
color = self.get_color()
color2 = (color[0], saturation, color[2], color[3])
try:
if rapid:
self.fire_and_forget(LightSetColor, {"color": color2, "duration": duration}, num_repeats=1)
else:
self.req_with_ack(LightSetColor, {"color": color2, "duration": duration})
except WorkflowException as e:
raise | def set_saturation(self, saturation, duration=0, rapid=False) | saturation to set
duration in ms | 3.995756 | 4.171979 | 0.95776 |
color = self.get_color()
color2 = (color[0], color[1], brightness, color[3])
try:
if rapid:
self.fire_and_forget(LightSetColor, {"color": color2, "duration": duration}, num_repeats=1)
else:
self.req_with_ack(LightSetColor, {"color": color2, "duration": duration})
except WorkflowException as e:
raise | def set_brightness(self, brightness, duration=0, rapid=False) | brightness to set
duration in ms | 3.938468 | 4.167599 | 0.945021 |
color = self.get_color()
color2 = (color[0], color[1], color[2], kelvin)
try:
if rapid:
self.fire_and_forget(LightSetColor, {"color": color2, "duration": duration}, num_repeats=1)
else:
self.req_with_ack(LightSetColor, {"color": color2, "duration": duration})
except WorkflowException as e:
raise | def set_colortemp(self, kelvin, duration=0, rapid=False) | kelvin: color temperature to set
duration in ms | 3.90393 | 4.063487 | 0.960734 |
step = Step(step)
result = set()
movement = {
"U": "RFLB",
"D": "LFRB",
"R": "FUBD",
"L": "FDBU",
"F": "URDL",
"B": "ULDR",
}[step.face]
movement = {
movement[i]: movement[(i + step.is_clockwise + (-1 * step.is_counter_clockwise) + (2 * step.is_180)) % 4]
for i in range(4)
}
for edge in edges:
if step.face not in edge:
result.add(edge.copy())
else:
k = (set(edge.facings.keys()) - {step.face}).pop()
new_edge = Edge(**{
step.face: edge[step.face],
movement[k]: edge[k],
})
result.add(new_edge)
return result | def _rotate(edges, step) | Simulate the cube rotation by updating four edges. | 3.707393 | 3.541986 | 1.046699 |
centres, edges = state
acts = sum([
[s, s.inverse(), s * 2] for s in
map(Step, "RUFDRB".replace(last_action.face if last_action else "", "", 1))
], [])
for step in acts:
yield step, (centres, CrossSolver._rotate(edges, step)) | def cross_successors(state, last_action=None) | Successors function for solving the cross. | 16.187838 | 14.824942 | 1.091933 |
centres, edges = state
for edge in edges:
if "D" not in edge.facings:
return False
if edge["D"] != centres["D"]["D"]:
return False
k = "".join(edge.facings.keys()).replace("D", "")
if edge[k] != centres[k][k]:
return False
return True | def cross_goal(state) | The goal function for cross solving search. | 5.553048 | 5.263967 | 1.054917 |
centres, edges = state
value = 0
for edge in edges:
if "U" in edge:
if edge["U"] == centres["D"]["D"]:
value += 1
else:
value += 2
elif "D" in edge:
if edge["D"] != centres["D"]["D"]:
value += 3
else:
value += 1
edgeposes = {}
counts = {f: 0 for f in "LFRB"}
ngedges = []
for edge in edges:
if "U" in edge and edge["U"] == centres["D"]["D"]:
k = "".join(edge.facings.keys()).replace("U", "")
edgeposes[k] = edge[k]
counts[k] += 1
elif "D" in edge and edge["D"] == centres["D"]["D"]:
k = "".join(edge.facings.keys()).replace("D", "")
edgeposes[k] = edge[k]
counts[k] += 1
elif "U" in edge or "D" in edge:
ngedges.append(edge)
else:
for k, s in edge:
if s != centres["D"]["D"]:
edgeposes[k] = s
counts[k] += 1
break
for edge in ngedges:
idx = "LFRB".index(edge[centres["D"].colour])
for i in [-1, 1]:
if "LFRB"[(idx+1)%4] not in edgeposes:
k = "".join(edge.facings.keys()).replace("LFRB"[idx], "")
edgeposes["LFRB"[(idx+1)%4]] = edge[k]
counts["LFRB"[(idx+1)%4]] += 1
break
else:
k = "".join(edge.facings.keys()).replace("LFRB"[idx], "")
if counts["LFRB"[(idx-1)%4]] > counts["LFRB"[(idx+1)%4]]:
edgeposes["LFRB"[(idx-1)%4]] = edge[k]
else:
edgeposes["LFRB"[(idx+1)%4]] = edge[k]
relative_pos = {f: centres[f][f] for f in "LFRB"}
if len(edgeposes) == 4:
for i in range(4):
edgeposes["L"], edgeposes["F"], edgeposes["R"], edgeposes["B"] = \
edgeposes["F"], edgeposes["R"], edgeposes["B"], edgeposes["L"]
if edgeposes == relative_pos:
break
else:
value += 5
else:
value += 3
return value | def cross_state_value(state) | Compute the state value of the cross solving search. | 2.360466 | 2.333623 | 1.011503 |
result = Formula(path_actions(a_star_search(
({f: self.cube[f] for f in "LUFDRB"},
self.cube.select_type("edge") & self.cube.has_colour(self.cube["D"].colour)),
self.cross_successors,
self.cross_state_value,
self.cross_goal,
)))
self.cube(result)
return result | def solve(self) | Solve the cross. | 16.411354 | 14.569864 | 1.12639 |
return self.cross_goal(({f: self.cube[f] for f in "LUFDRB"},
self.cube.select_type("edge") & self.cube.has_colour(self.cube["D"].colour))) | def is_solved(self) | Check if the cross of Cube is solved. | 28.547583 | 22.300062 | 1.280157 |
result = ""
for side in "LFRB":
for square in self.cube.get_face(side)[0]:
for _side in "LFRB":
if square.colour == self.cube[_side].colour:
result += _side
break
return result | def recognise(self) | Recognise the PLL case of Cube. | 6.088427 | 5.415151 | 1.124332 |
if not isinstance(self.cube, Cube):
raise ValueError("Use Solver.feed(cube) to feed the cube to solver.")
for i in range(4):
rec_id = self.recognise()
if rec_id in algo_dict:
self.cube(algo_dict[rec_id])
return Formula((Step("y") * i) or []) + algo_dict[rec_id]
self.cube(Step("y"))
raise ValueError("Invalid cube.") | def solve(self) | Solve PLL of Cube. | 9.141041 | 8.362062 | 1.093156 |
for side in "LUFDRB":
sample = self.cube[side].facings[side]
for square in sum(self.cube.get_face(side), []):
if square != sample:
return False
return True | def is_solved(self) | Check if Cube is solved. | 10.130354 | 7.652714 | 1.32376 |
if not isinstance(self.cube, Cube):
raise ValueError("Use Solver.feed(cube) to feed the cube to solver.")
result = ""
for face in "LFRB":
for square in self.cube.get_face(face)[0]:
result += str(int(square == self.cube["U"]["U"]))
if result not in algo_dict:
raise ValueError("Invalid Cube, probably didn't solve F2L, or wrong input value.\nUse Solver.feed(cube) to reset the cube.")
self.case = result
return result | def recognise(self) | Recognise which is Cube's OLL case. | 9.521786 | 8.526415 | 1.11674 |
if not isinstance(self.cube, Cube):
raise ValueError("Use Solver.feed(cube) to feed the cube to solver.")
self.recognise()
self.cube(algo_dict[self.case])
return algo_dict[self.case] | def solve(self) | Solve the OLL. Returns an Formula. | 11.114757 | 10.387413 | 1.070022 |
if is_goal(start):
return [start]
explored = []
g = 1
h = state_value(start)
f = g + h
p = [start]
frontier = [(f, g, h, p)]
while frontier:
f, g, h, path = frontier.pop(0)
s = path[-1]
for (action, state) in successors(s, path_actions(path)[-1] if len(path) != 1 else []):
if state not in explored:
explored.append(state)
path2 = path + [action, state]
h2 = state_value(state)
g2 = g + 1
f2 = h2 + g2
if is_goal(state):
return path2
else:
frontier.append((f2, g2, h2, path2))
frontier.sort(key=lambda x:x[:3])
return [] | def a_star_search(start, successors, state_value, is_goal) | This is a searching function of A* | 2.488321 | 2.503872 | 0.993789 |
self.cube = cube
if pair not in ["FR", "RB", "BL", "LF"]:
pair = ["FR", "RB", "BL", "LF"][["RF", "BR", "LB", "FL"].index(pair)]
self.pair = pair | def feed(self, cube, pair) | Feed Cube to the solver. | 4.264509 | 3.962042 | 1.076341 |
colours = (
self.cube[self.pair[0]].colour,
self.cube[self.pair[1]].colour,
self.cube["D"].colour
)
result_corner = self.cube.children.copy()
for c in colours[:2]:
result_corner &= self.cube.has_colour(c)
result_edge = result_corner & self.cube.select_type("edge")
result_corner &= self.cube.has_colour(colours[2])
return (list(result_corner)[0], list(result_edge)[0]) | def get_pair(self) | Get the F2L pair (corner, edge). | 4.558363 | 4.187068 | 1.088677 |
corner = {"D":self.cube["D"]["D"]}
edge = {}
for cubie in (corner, edge):
for face in self.pair:
cubie.update({face:self.cube[face][face]})
return (Corner(**corner), Edge(**edge)) | def estimated_position(self) | Get the estimated cubie of solved pair. | 9.939802 | 6.989519 | 1.422101 |
corner, edge = self.get_pair()
corner_slot, edge_slot = corner.location.replace("D", "", 1), edge.location
if "U" not in corner_slot and corner_slot not in ["FR", "RB", "BL", "LF"]:
corner_slot = ["FR", "RB", "BL", "LF"][["RF", "BR", "LB", "FL"].index(corner_slot)]
if "U" not in edge_slot and edge_slot not in ["FR", "RB", "BL", "LF"]:
edge_slot = ["FR", "RB", "BL", "LF"][["RF", "BR", "LB", "FL"].index(edge_slot)]
if "U" in corner_slot and "U" in edge_slot:
return ("SLOTFREE", (None, None), (corner, edge))
if "U" in corner_slot:
return ("CSLOTFREE", (None, edge_slot), (corner, edge))
if "U" in edge_slot:
return ("ESLOTFREE", (corner_slot, None), (corner, edge))
if corner_slot not in [edge_slot, edge_slot[::-1]]:
return ("DIFFSLOT", (corner_slot, edge_slot), (corner, edge))
if (corner, edge) == self.estimated_position():
return ("SOLVED", (corner_slot, edge_slot), (corner, edge))
return ("WRONGSLOT", (corner_slot, edge_slot), (corner, edge)) | def get_slot(self) | Get the slot position of this pair. | 2.543101 | 2.468649 | 1.030159 |
((corner, edge), (L, U, F, D, R, B)) = state
if "U" not in corner or "U" not in edge: return False
if set(edge).issubset(set(corner)): return True
elif set(edge.facings.keys()).issubset(set(corner.facings.keys())): return False
opposite = {"L":"R", "R":"L", "F":"B", "B":"F"}
edge_facings = list(edge)
for i, (face, square) in enumerate(edge_facings):
if face == "U":
if square != corner[opposite[edge_facings[(i+1)%2][0]]]:
return False
else:
if square != corner["U"]:
return False
return True | def combining_goal(state) | Check if two Cubies are combined on the U face. | 3.811767 | 3.481821 | 1.094763 |
step = Step(step)
movement = {
"U": "RFLB",
"D": "LFRB",
"R": "FUBD",
"L": "FDBU",
"F": "URDL",
"B": "ULDR",
}[step.face]
movement = {
movement[i]: movement[(i + step.is_clockwise + (-1 * step.is_counter_clockwise) + (2 * step.is_180)) % 4]
for i in range(4)
}
for cubie in pair:
if step.face not in cubie:
if cubie.type == "edge":
result_edge = cubie.copy()
else:
result_corner = cubie.copy()
else:
result = {}
for face, square in cubie:
if face not in movement:
result[face] = square
else:
result[movement[face]] = square
if len(result) == 2:
result_edge = Edge(**result)
else:
result_corner = Corner(**result)
return (result_corner, result_edge) | def _rotate(pair, step) | Simulate the cube rotation by updating the pair. | 3.331873 | 3.200029 | 1.041201 |
((corner, edge), (L, U, F, D, R, B)) = state
U_turns = [Formula("U"), Formula("U'"), Formula("U2")] if len(last_action) != 1 else []
R_turns = [Formula("R U R'"), Formula("R U' R'"), Formula("R U2 R'")] if "R" not in last_action else []
F_turns = [Formula("F' U F"), Formula("F' U' F"), Formula("F' U2 F")] if "F" not in last_action else []
for act in (U_turns + R_turns + F_turns):
new = (corner, edge)
for q in act:
new = F2LPairSolver._rotate(new, q)
yield act, (new, (L, U, F, D, R, B)) | def combining_successors(state, last_action=()) | Successors function for finding path of combining F2L pair. | 4.176534 | 3.757812 | 1.111427 |
start = (
self.get_pair(),
(
self.cube["L"],
self.cube["U"],
self.cube["F"],
self.cube["D"],
self.cube["R"],
self.cube["B"],
),
)
return sum(path_actions(a_star_search(start,
self.combining_successors,
lambda x: len(x),
self.combining_goal)), Formula()) | def combining_search(self) | Searching the path for combining the pair. | 7.56697 | 6.661366 | 1.135949 |
(slot_type, (corner_slot, edge_slot), (corner, edge)) = self.get_slot()
cycle = ["FR", "RB", "BL", "LF"]
if slot_type == "SLOTFREE":
return ("FR", Formula(Step("y") * cycle.index(self.pair) or []))
elif slot_type == "CSLOTFREE":
return (cycle[-(cycle.index(edge_slot) - cycle.index(self.pair))],
Formula(Step("y") * cycle.index(edge_slot) or []))
elif slot_type in ("ESLOTFREE", "WRONGSLOT"):
return (cycle[-(cycle.index(corner_slot) - cycle.index(self.pair))],
Formula(Step("y") * cycle.index(corner_slot) or []))
elif slot_type == "DIFFSLOT":
if corner_slot != self.pair: corner_slot, edge_slot = edge_slot, corner_slot
result = Formula(Step("y") * cycle.index(edge_slot) or [])
result += Formula("R U R'")
result += Formula(Step("y'") * cycle.index(edge_slot) or [])
result += Formula(Step("y") * cycle.index(corner_slot) or [])
if result[-1].face == "y" and result[-2].face == "y":
result[-2] += result[-1]
del result[-1]
return (cycle[-(cycle.index(corner_slot) - cycle.index(self.pair))], result)
else:
return (cycle[-cycle.index(self.pair)], Formula()) | def combining_setup(self) | Setup for some special F2L cases. | 3.364969 | 3.235023 | 1.040168 |
self.pair, setup = self.combining_setup()
self.cube(setup)
actual = self.combining_search()
self.cube(actual)
return setup + actual | def combine(self) | Combine the pair. | 14.156925 | 11.102571 | 1.275103 |
cycle = ["FR", "RB", "BL", "LF"]
combine = self.combine()
put = Formula(Step("y") * cycle.index(self.pair) or [])
self.cube(put)
self.pair = "FR"
estimated = self.estimated_position()
for U_act in [Formula(), Formula("U"), Formula("U2"), Formula("U'")]:
self.cube(U_act)
for put_act in [Formula("R U R'"), Formula("R U' R'"), Formula("R U2 R'"),
Formula("F' U F"), Formula("F' U' F"), Formula("F' U2 F")]:
self.cube(put_act)
if self.get_pair() == estimated:
return combine + put + U_act + put_act
self.cube(put_act.reverse())
self.cube(U_act.reverse()) | def solve(self) | Solve the pair. | 6.339227 | 5.969325 | 1.061967 |
for i in range(4):
for slot in ["FR", "RB", "BL", "LF"]:
solver = F2LPairSolver(self.cube, slot)
if not solver.is_solved():
yield tuple([self.cube[slot[i]].colour for i in range(2)]), solver.solve()
break | def solve(self) | Solve the entire F2L. (Generator) | 9.592141 | 7.736966 | 1.239781 |
if self.cube.D == [[Square(self.cube["D"].colour)] * 3] * 3:
for face in "LFRB":
if self.cube.get_face(face)[1:] != [[Square(self.cube[face].colour)] * 3] * 2:
return False
return True
return False | def is_solved(self) | Check if Cube's F2L is solved. | 5.884432 | 5.058794 | 1.163209 |
return self.post(
'https://{}/oauth/token'.format(self.domain),
data={
'client_id': client_id,
'client_secret': client_secret,
'code': code,
'grant_type': grant_type,
'redirect_uri': redirect_uri,
},
headers={'Content-Type': 'application/json'}
) | def authorization_code(self, client_id, client_secret, code,
redirect_uri, grant_type='authorization_code') | Authorization code grant
This is the OAuth 2.0 grant that regular web apps utilize in order
to access an API. Use this endpoint to exchange an Authorization Code
for a Token.
Args:
grant_type (str): Denotes the flow you're using. For authorization code
use authorization_code
client_id (str): your application's client Id
client_secret (str): your application's client Secret
code (str): The Authorization Code received from the /authorize Calls
redirect_uri (str, optional): This is required only if it was set at
the GET /authorize endpoint. The values must match
Returns:
access_token, id_token | 1.763761 | 2.0155 | 0.875099 |
return self.post(
'https://{}/oauth/token'.format(self.domain),
data={
'client_id': client_id,
'code_verifier': code_verifier,
'code': code,
'grant_type': grant_type,
'redirect_uri': redirect_uri,
},
headers={'Content-Type': 'application/json'}
) | def authorization_code_pkce(self, client_id, code_verifier, code,
redirect_uri, grant_type='authorization_code') | Authorization code pkce grant
This is the OAuth 2.0 grant that mobile apps utilize in order to access an API.
Use this endpoint to exchange an Authorization Code for a Token.
Args:
grant_type (str): Denotes the flow you're using. For authorization code pkce
use authorization_code
client_id (str): your application's client Id
code_verifier (str): Cryptographically random key that was used to generate
the code_challenge passed to /authorize.
code (str): The Authorization Code received from the /authorize Calls
redirect_uri (str, optional): This is required only if it was set at
the GET /authorize endpoint. The values must match
Returns:
access_token, id_token | 1.805644 | 2.071951 | 0.87147 |
return self.post(
'https://{}/oauth/token'.format(self.domain),
data={
'client_id': client_id,
'client_secret': client_secret,
'audience': audience,
'grant_type': grant_type,
},
headers={'Content-Type': 'application/json'}
) | def client_credentials(self, client_id, client_secret, audience,
grant_type='client_credentials') | Client credentials grant
This is the OAuth 2.0 grant that server processes utilize in
order to access an API. Use this endpoint to directly request
an access_token by using the Application Credentials (a Client Id and
a Client Secret).
Args:
grant_type (str): Denotes the flow you're using. For client credentials
use client_credentials
client_id (str): your application's client Id
client_secret (str): your application's client Secret
audience (str): The unique identifier of the target API you want to access.
Returns:
access_token | 1.904908 | 2.239476 | 0.850604 |
return self.post(
'https://{}/oauth/token'.format(self.domain),
data={
'client_id': client_id,
'username': username,
'password': password,
'realm': realm,
'client_secret': client_secret,
'scope': scope,
'audience': audience,
'grant_type': grant_type
},
headers={'Content-Type': 'application/json'}
) | def login(self, client_id, client_secret, username, password, scope, realm,
audience, grant_type='http://auth0.com/oauth/grant-type/password-realm') | Calls oauth/token endpoint with password-realm grant type
This is the OAuth 2.0 grant that highly trusted apps utilize in order
to access an API. In this flow the end-user is asked to fill in credentials
(username/password) typically using an interactive form in the user-agent
(browser). This information is later on sent to the client and Auth0.
It is therefore imperative that the client is absolutely trusted with
this information.
Args:
grant_type (str): Denotes the flow you're using. For password realm
use http://auth0.com/oauth/grant-type/password-realm
client_id (str): your application's client Id
client_secret (str): your application's client Secret
audience (str): The unique identifier of the target API you want to access.
username (str): Resource owner's identifier
password (str): resource owner's Secret
scope(str): String value of the different scopes the client is asking for.
Multiple scopes are separated with whitespace.
realm (str): String value of the realm the user belongs.
Set this if you want to add realm support at this grant.
Returns:
access_token, id_token | 1.737282 | 2.046097 | 0.849071 |
return self.post(
'https://{}/oauth/token'.format(self.domain),
data={
'client_id': client_id,
'client_secret': client_secret,
'refresh_token': refresh_token,
'grant_type': grant_type
},
headers={'Content-Type': 'application/json'}
) | def refresh_token(self, client_id, client_secret, refresh_token, grant_type='refresh_token') | Calls oauth/token endpoint with refresh token grant type
Use this endpoint to refresh an access token, using the refresh token you got during authorization.
Args:
grant_type (str): Denotes the flow you're using. For refresh token
use refresh_token
client_id (str): your application's client Id
client_secret (str): your application's client Secret
refresh_token (str): The refresh token returned from the initial token request.
Returns:
access_token, id_token | 1.858996 | 2.068162 | 0.898864 |
params = {'fields': fields and ','.join(fields) or None,
'include_fields': str(include_fields).lower()}
return self.client.get(self._url(id), params=params) | def get(self, id, fields=None, include_fields=True) | Retrieve connection by id.
Args:
id (str): Id of the connection to get.
fields (list of str, optional): A list of fields to include or
exclude from the result (depending on include_fields). Empty to
retrieve all fields.
include_fields (bool, optional): True if the fields specified are
to be included in the result, False otherwise.
See: https://auth0.com/docs/api/management/v2#!/Connections/get_connections_by_id
Returns:
A connection object. | 2.749123 | 4.494384 | 0.61168 |
return self.client.patch(self._url(id), data=body) | def update(self, id, body) | Modifies a connection.
Args:
id: Id of the connection.
body (dict): Specifies which fields are to be modified, and to what
values.
See: https://auth0.com/docs/api/management/v2#!/Connections/patch_connections_by_id
Returns:
The modified connection object. | 7.507702 | 9.099824 | 0.825038 |
return self.client.post(self._url(), data=body) | def create(self, body) | Creates a new connection.
Args:
body (dict): Attributes used to create the connection. Mandatory
attributes are: 'name' and 'strategy'.
See: https://auth0.com/docs/api/management/v2#!/Connections/post_connections | 7.57637 | 9.306767 | 0.814071 |
return self.client.delete(self._url(id) + '/users', params={'email': email}) | def delete_user_by_email(self, id, email) | Deletes a specified connection user by its email.
Args:
id (str): The id of the connection (must be a database connection).
email (str): The email of the user to delete.
See: https://auth0.com/docs/api/management/v2#!/Connections/delete_users_by_email
Returns:
An empty dict. | 5.108374 | 6.579799 | 0.776372 |
params = {
'fields': fields and ','.join(fields) or None,
'include_fields': str(include_fields).lower(),
'user_id': user_id,
'client_id': client_id,
'type': type,
}
return self.client.get(self._url(), params=params) | def get(self, user_id, client_id, type, fields=None, include_fields=True) | List device credentials.
Args:
user_id (str): The user_id of the devices to retrieve.
client_id (str): The client_id of the devices to retrieve.
type (str): The type of credentials (public_key, refresh_token).
fields (list, optional): A list of fields to include or exclude
(depending on include_fields) from the result, empty to
retrieve all fields
include_fields (bool, optional): True if the fields specified are
to be included in the result, False otherwise
(defaults to true)
See: https://auth0.com/docs/api/management/v2#!/Device_Credentials/get_device_credentials | 2.004978 | 2.567533 | 0.780897 |
url = self._url('%s' % (id))
return self.client.get(url) | def get(self, id) | Retrieves custom domain.
See: https://auth0.com/docs/api/management/v2#!/Custom_Domains/get_custom_domains_by_id | 5.217659 | 5.935693 | 0.879031 |
url = self._url('%s' % (id))
return self.client.delete(url) | def delete(self, id) | Deletes a grant.
Args:
id (str): The id of the custom domain to delete
See: https://auth0.com/docs/api/management/v2#!/Custom_Domains/delete_custom_domains_by_id | 5.309133 | 7.897342 | 0.672268 |
return self.client.post(self._url(), data=body) | def create_new(self, body) | Configure a new custom domain
Args:
body (str): The domain, tye and verification method in json
See: https://auth0.com/docs/api/management/v2#!/Custom_Domains/post_custom_domains | 6.468591 | 10.08931 | 0.641133 |
url = self._url('%s/verify' % (id))
return self.client.post(url) | def verify(self, id) | Verify a custom domain
Args:
id (str): The id of the custom domain to delete
See: https://auth0.com/docs/api/management/v2#!/Custom_Domains/post_verify | 5.857134 | 8.322533 | 0.703768 |
return self.get(url='https://{}/samlp/metadata/{}'.format(self.domain,
client_id)) | def saml_metadata(self, client_id) | Get SAML2.0 Metadata.
Args:
client_id (str): Client Id of the application to get the SAML metadata for. | 7.575033 | 9.643772 | 0.785484 |
url = 'https://{}/wsfed/FederationMetadata' \
'/2007-06/FederationMetadata.xml'
return self.get(url=url.format(self.domain)) | def wsfed_metadata(self) | Returns the WS-Federation Metadata. | 5.457495 | 4.265767 | 1.27937 |
return_to = quote_plus(return_to)
if federated is True:
return self.get(
'https://{}/v2/logout?federated&client_id={}&returnTo={}'.format(
self.domain, client_id, return_to),
headers={'Content-Type': 'application/json'}
)
return self.get(
'https://{}/v2/logout?client_id={}&returnTo={}'.format(self.domain,
client_id,
return_to),
headers={'Content-Type': 'application/json'}
) | def logout(self, client_id, return_to, federated=False) | Logout
Use this endpoint to logout a user. If you want to navigate the user to a
specific URL after the logout, set that URL at the returnTo parameter.
The URL should be included in any the appropriate Allowed Logout URLs list:
Args:
client_id (str): The client_id of your application.
returnTo (str): URL to redirect the user after the logout.
federated (bool): Querystring parameter to log the user out of the IdP | 1.984084 | 2.186477 | 0.907434 |
params = extra_params or {}
params['fields'] = fields and ','.join(fields) or None
params['include_fields'] = str(include_fields).lower()
params['page'] = page
params['per_page'] = per_page
return self.client.get(self._url(), params=params) | def all(self, fields=None, include_fields=True, page=None, per_page=None, extra_params=None) | Retrieves a list of all the applications.
Important: The client_secret and encryption_key attributes can only be
retrieved with the read:client_keys scope.
Args:
fields (list of str, optional): A list of fields to include or
exclude from the result (depending on include_fields). Empty to
retrieve all fields.
include_fields (bool, optional): True if the fields specified are
to be included in the result, False otherwise.
page (int): The result's page number (zero based).
per_page (int, optional): The amount of entries per page.
extra_params (dictionary, optional): The extra parameters to add to
the request. The fields, include_fields, page and per_page values
specified as parameters take precedence over the ones defined here.
See: https://auth0.com/docs/api/management/v2#!/Clients/get_clients | 1.916882 | 2.42925 | 0.789084 |
params = {'id': id }
url = self._url('%s/rotate-secret' % id)
return self.client.get(url, params=params) | def rotate_secret(self, id) | Rotate a client secret. The generated secret is NOT base64 encoded.
Args:
id (str): Client ID of the application.
body (dict): Attributes to modify.
See: https://auth0.com/docs/api/management/v2#!/Clients/post_rotate_secret | 5.628572 | 9.725123 | 0.578766 |
return self.post(
'https://{}/passwordless/start'.format(self.domain),
data={
'client_id': client_id,
'connection': 'email',
'email': email,
'send': send,
'authParams': auth_params
},
headers={'Content-Type': 'application/json'}
) | def email(self, client_id, email, send='link', auth_params=None) | Start flow sending an email.
Given the user email address, it will send an email with:
- A link (default, send:"link"). You can then authenticate with
this user opening the link and he will be automatically logged in
to the application. Optionally, you can append/override
parameters to the link (like scope, redirect_uri, protocol,
response_type, etc.) using auth_params dict.
- A verification code (send:"code"). You can then authenticate with
this user using email as username and code as password.
Args:
client_id (str): Client Id of the application.
email (str): Email address.
send (str, optional): Can be: 'link' or 'code'. Defaults to 'link'.
auth_params (dict, optional): Parameters to append or override. | 2.708898 | 3.110254 | 0.870957 |
return self.post(
'https://{}/passwordless/start'.format(self.domain),
data={
'client_id': client_id,
'connection': 'sms',
'phone_number': phone_number,
},
headers={'Content-Type': 'application/json'}
) | def sms(self, client_id, phone_number) | Start flow sending a SMS message. | 3.125499 | 2.943097 | 1.061976 |
return self.post(
'https://{}/oauth/ro'.format(self.domain),
data={
'client_id': client_id,
'connection': 'sms',
'grant_type': 'password',
'username': phone_number,
'password': code,
'scope': scope,
},
headers={'Content-Type': 'application/json'}
) | def sms_login(self, client_id, phone_number, code, scope='openid') | Login using phone number/verification code. | 2.525409 | 2.561875 | 0.985766 |
params = {
'client_id': client_id,
'audience': audience,
'response_type': response_type,
'scope': scope,
'state': state,
'redirect_uri': redirect_uri
}
return self.get(
'https://{}/authorize'.format(self.domain),
params=params) | def authorize(self, client_id, audience=None, state=None, redirect_uri=None,
response_type='code', scope='openid') | Authorization code grant
This is the OAuth 2.0 grant that regular web apps utilize in order to access an API. | 1.958073 | 1.940495 | 1.009058 |
params = {
'page': page,
'per_page': per_page,
'include_totals': str(include_totals).lower()
}
return self.client.get(self._url(), params=params) | def get_all(self, page=None, per_page=None, include_totals=False) | Retrieves all resource servers
Args:
page (int, optional): The result's page number (zero based).
per_page (int, optional): The amount of entries per page.
include_totals (bool, optional): True if the query summary is
to be included in the result, False otherwise.
See: https://auth0.com/docs/api/management/v2#!/Resource_Servers/get_resource_servers | 2.203639 | 2.996452 | 0.735416 |
params = {'identifier': identifier}
return self.client.get(self._url(), params=params) | def get_by_identifier(self, identifier) | Gets blocks by identifier
Args:
identifier (str): Should be any of: username, phone_number, email.
See: https://auth0.com/docs/api/management/v2#!/User_Blocks/get_user_blocks | 5.715847 | 7.164785 | 0.797769 |
params = {'identifier': identifier}
return self.client.delete(self._url(), params=params) | def unblock_by_identifier(self, identifier) | Unblocks by identifier
Args:
identifier (str): Should be any of: username, phone_number, email.
See: https://auth0.com/docs/api/management/v2#!/User_Blocks/delete_user_blocks | 5.973649 | 7.755691 | 0.770228 |
if id_token and refresh_token:
raise ValueError('Only one of id_token or refresh_token '
'can be None')
data = {
'client_id': client_id,
'grant_type': grant_type,
'target': target,
'scope': scope,
'api_type': api_type,
}
if id_token:
data.update({'id_token': id_token})
elif refresh_token:
data.update({'refresh_token': refresh_token})
else:
raise ValueError('Either id_token or refresh_token must '
'have a value')
return self.post(
'https://{}/delegation'.format(self.domain),
headers={'Content-Type': 'application/json'},
data=data
) | def get_token(self, client_id, target, api_type, grant_type,
id_token=None, refresh_token=None, scope='openid') | Obtain a delegation token. | 1.948345 | 1.900899 | 1.02496 |
url = self._url('factors/{}'.format(name))
return self.client.put(url, data=body) | def update_factor(self, name, body) | Update Guardian factor
Useful to enable / disable factor
Args:
name (str): Either push-notification or sms
body (dict): Attributes to modify.
See: https://auth0.com/docs/api/management/v2#!/Guardian/put_factors_by_name | 4.044229 | 4.697304 | 0.860968 |
return self.client.put(self._url('factors/sms/templates'), data=body) | def update_templates(self, body) | Update enrollment and verification SMS templates.
Useful to send custom messages on sms enrollment and verification
Args:
body (dict): Attributes to modify.
See: https://auth0.com/docs/api/management/v2#!/Guardian/put_templates | 16.762316 | 11.223428 | 1.493511 |
url = self._url('enrollments/{}'.format(id))
return self.client.get(url) | def get_enrollment(self, id) | Retrieves an enrollment.
Useful to check its type and related metadata.
Args:
id (str): The id of the device account to update
See: https://auth0.com/docs/api/management/v2#!/Guardian/get_enrollments_by_id | 4.129816 | 5.470727 | 0.754893 |
url = self._url('enrollments/{}'.format(id))
return self.client.delete(url) | def delete_enrollment(self, id) | Deletes an enrollment.
Useful when you want to force re-enroll.
Args:
id (str): The id of the device account to update
See: https://auth0.com/docs/api/management/v2#!/Guardian/delete_enrollments_by_id | 3.876691 | 5.571802 | 0.69577 |
return self.client.post(self._url('enrollments/ticket'), data=body) | def create_enrollment_ticket(self, body) | Creates an enrollment ticket for user_id
A useful way to send an email to a user, with a link that lead to
start the enrollment process
Args:
body (dict): Details of the user to send the ticket to.
See: https://auth0.com/docs/api/management/v2#!/Guardian/post_ticket | 6.352098 | 8.411755 | 0.755145 |
url = self._url('factors/{}/providers/{}'.format(factor_name, name))
return self.client.get(url) | def get_factor_providers(self, factor_name, name) | Get Guardian SNS or SMS factor providers.
Returns provider configuration
Args:
factor_name (str): Either push-notification or sms
name (str): Name of the provider
See: https://auth0.com/docs/api/management/v2#!/Guardian/get_sns
https://auth0.com/docs/api/management/v2#!/Guardian/get_twilio | 4.338625 | 5.406005 | 0.802557 |
url = self._url('factors/{}/providers/{}'.format(factor_name, name))
return self.client.put(url, data=body) | def update_factor_providers(self, factor_name, name, body) | Get Guardian factor providers.
Returns provider configuration
Args:
factor_name (str): Either push-notification or sms
name (str): Name of the provider
body (dict):
See: https://auth0.com/docs/api/management/v2#!/Guardian/put_twilio | 3.366681 | 4.024854 | 0.836473 |
body = {
'client_id': client_id,
'token': token,
'client_secret': client_secret
}
return self.post(
'https://{}/oauth/revoke'.format(self.domain), data=body) | def revoke_refresh_token(self, client_id, token, client_secret=None) | Revokes a Refresh Token if it has been compromised
Each revocation request invalidates not only the specific token, but all other tokens
based on the same authorization grant. This means that all Refresh Tokens that have
been issued for the same user, application, and audience will be revoked.
Args:
client_id (str): The Client ID for your Application
token (str): The Refresh Token you want to revoke
client_secret (str, optional): The Client Secret for your Application.
Required for confidential applications.
See: https://auth0.com/docs/applications/application-types#confidential-applications
See: https://auth0.com/docs/api/authentication#refresh-token | 2.694438 | 2.908199 | 0.926497 |
params = {
'key': key
}
return self.client.delete(self._url(), params=params) | def unset(self, key) | Removes the rules config for a given key.
Args:
key (str): rules config key to remove
See: https://auth0.com/docs/api/management/v2#!/Rules_Configs/delete_rules_configs_by_key | 4.799862 | 5.609429 | 0.855677 |
url = self._url('{}'.format(key))
body = {'value': value}
return self.client.put(url, data=body) | def set(self, key, value) | Sets the rules config for a given key.
Args:
key (str): rules config key to set
value (str): value to set for the rules config key
See: https://auth0.com/docs/api/management/v2#!/Rules_Configs/put_rules_configs_by_key | 4.943677 | 5.434817 | 0.909631 |
return self.client.get(self._url('daily'), params={'from': from_date,
'to': to_date}) | def daily_stats(self, from_date=None, to_date=None) | Gets the daily stats for a particular period.
Args:
from_date (str): The first day of the period (inclusive) in
YYYYMMDD format.
to_date (str): The last day of the period (inclusive) in
YYYYMMDD format.
See: https://auth0.com/docs/api/management/v2#!/Stats/get_daily | 4.751862 | 5.665533 | 0.838732 |
return self.client.post(self._url('email-verification'), data=body) | def create_email_verification(self, body) | Create an email verification ticket.
Args:
body (dict): Please see: https://auth0.com/docs/api/v2#!/Tickets/post_email_verification | 5.458899 | 6.638019 | 0.822369 |
return self.client.post(self._url('password-change'), data=body) | def create_pswd_change(self, body) | Create password change ticket.
Args:
body (dict): Please see: https://auth0.com/docs/api/v2#!/Tickets/post_password_change | 6.031962 | 6.824241 | 0.883902 |
params = {
'per_page': per_page,
'page': page,
'include_totals': str(include_totals).lower(),
'sort': sort,
'fields': fields and ','.join(fields) or None,
'include_fields': str(include_fields).lower(),
'q': q,
'from': from_param,
'take': take
}
return self.client.get(self._url(), params=params) | def search(self, page=0, per_page=50, sort=None, q=None,
include_totals=True, fields=None, from_param=None, take=None,
include_fields=True) | Search log events.
Args:
page (int, optional): The result's page number (zero based).
per_page (int, optional): The amount of entries per page.
sort (str, optional): The field to use for sorting.
1 == ascending and -1 == descending. (e.g: date:1)
q (str, optional): Query in Lucene query string syntax.
fields (list of str, optional): A list of fields to include or
exclude from the result (depending on include_fields). Empty to
retrieve all fields.
include_fields (bool, optional): True if the fields specified are
to be included in the result, False otherwise.
include_totals (bool, optional): True if the query summary is
to be included in the result, False otherwise.
from_param (str, optional): Log Event Id to start retrieving logs. You can
limit the amount of logs using the take parameter
take (int, optional): The total amount of entries to retrieve when
using the from parameter.
https://auth0.com/docs/api/management/v2#!/Logs/get_logs | 1.811621 | 2.166885 | 0.836048 |
params = {
'audience': audience,
'page': page,
'per_page': per_page,
'include_totals': str(include_totals).lower(),
'client_id': client_id,
}
return self.client.get(self._url(), params=params) | def all(self, audience=None, page=None, per_page=None, include_totals=False, client_id=None) | Retrieves all client grants.
Args:
audience (str, optional): URL encoded audience of a Resource Server
to filter
page (int, optional): The result's page number (zero based).
per_page (int, optional): The amount of entries per page.
include_totals (bool, optional): True if the query summary is
to be included in the result, False otherwise.
client_id (string, optional): The id of a client to filter
See: https://auth0.com/docs/api/management/v2#!/Client_Grants/get_client_grants | 1.913783 | 2.434096 | 0.78624 |
return self.post(
'https://{}/oauth/access_token'.format(self.domain),
data={
'client_id': client_id,
'access_token': access_token,
'connection': connection,
'scope': scope,
},
headers={'Content-Type': 'application/json'}
) | def login(self, client_id, access_token, connection, scope='openid') | Login using a social provider's access token
Given the social provider's access_token and the connection specified,
it will do the authentication on the provider and return a dict with
the access_token and id_token. Currently, this endpoint only works for
Facebook, Google, Twitter and Weibo.
Args:
client_id (str): application's client id.
access_token (str): social provider's access_token.
connection (str): connection type (e.g: 'facebook')
Returns:
A dict with 'access_token' and 'id_token' keys. | 2.213387 | 2.292443 | 0.965515 |
params = {
'aud': aud
}
return self.client.get(self.url, params=params) | def get(self, aud=None) | Retrieves the jti and aud of all tokens in the blacklist.
Args:
aud (str, optional): The JWT's aud claim. The client_id of the
application for which it was issued.
See: https://auth0.com/docs/api/management/v2#!/Blacklists/get_tokens | 4.269926 | 6.18048 | 0.690873 |
return self.client.post(self.url, data={'jti': jti, 'aud': aud}) | def create(self, jti, aud='') | Adds a token to the blacklist.
Args:
jti (str): the jti of the JWT to blacklist.
aud (str, optional): The JWT's aud claim. The client_id of the
application for which it was issued.
body (dict):
See: https://auth0.com/docs/api/management/v2#!/Blacklists/post_tokens | 4.567363 | 5.335599 | 0.856017 |
params = {
'per_page': per_page,
'page': page,
'include_totals': str(include_totals).lower(),
'sort': sort,
'connection': connection,
'fields': fields and ','.join(fields) or None,
'include_fields': str(include_fields).lower(),
'q': q,
'search_engine': search_engine
}
return self.client.get(self._url(), params=params) | def list(self, page=0, per_page=25, sort=None, connection=None, q=None,
search_engine=None, include_totals=True, fields=None,
include_fields=True) | List or search users.
Args:
page (int, optional): The result's page number (zero based).
per_page (int, optional): The amount of entries per page.
sort (str, optional): The field to use for sorting.
1 == ascending and -1 == descending. (e.g: email:1)
connection (str, optional): Connection filter.
q (str, optional): Query in Lucene query string syntax. Only fields
in app_metadata, user_metadata or the normalized user profile
are searchable.
search_engine (str, optional): The version of the search_engine to use
when querying for users. Will default to the latest version available.
See: https://auth0.com/docs/users/search
fields (list of str, optional): A list of fields to include or
exclude from the result (depending on include_fields). Empty to
retrieve all fields.
include_fields (bool, optional): True if the fields specified are
to be include in the result, False otherwise.
See: https://auth0.com/docs/api/management/v2#!/Users/get_users | 1.893173 | 2.145692 | 0.882313 |
url = self._url('{}/multifactor/{}'.format(id, provider))
return self.client.delete(url) | def delete_multifactor(self, id, provider) | Delete a user's multifactor provider.
Args:
id (str): The user's id.
provider (str): The multifactor provider. Supported values 'duo'
or 'google-authenticator'
See: https://auth0.com/docs/api/management/v2#!/Users/delete_multifactor_by_provider | 4.406826 | 5.484723 | 0.803473 |
url = self._url('{}/identities/{}/{}'.format(id, provider, user_id))
return self.client.delete(url) | def unlink_user_account(self, id, provider, user_id) | Unlink a user account
Args:
id (str): The user_id of the user identity.
provider (str): The type of identity provider (e.g: facebook).
user_id (str): The unique identifier for the user for the identity.
See: https://auth0.com/docs/api/management/v2#!/Users/delete_user_identity_by_user_id | 4.372355 | 4.585881 | 0.953438 |
url = self._url('{}/identities'.format(user_id))
return self.client.post(url, data=body) | def link_user_account(self, user_id, body) | Link user accounts.
Links the account specified in the body (secondary account) to the
account specified by the id param of the URL (primary account).
Args:
id (str): The user_id of the primary identity where you are linking
the secondary account to.
body (dict): Please see: https://auth0.com/docs/api/v2#!/Users/post_identities | 5.279159 | 5.193938 | 1.016408 |
url = self._url('{}/recovery-code-regeneration'.format(user_id))
return self.client.post(url) | def regenerate_recovery_code(self, user_id) | Removes the current recovery token, generates and returns a new one
Args:
user_id (str): The user_id of the user identity.
See: https://auth0.com/docs/api/management/v2#!/Users/post_recovery_code_regeneration | 6.091826 | 5.541927 | 1.099225 |
url = self._url('{}/enrollments'.format(user_id))
return self.client.get(url) | def get_guardian_enrollments(self, user_id) | Retrieves all Guardian enrollments.
Args:
user_id (str): The user_id of the user to retrieve
See: https://auth0.com/docs/api/management/v2#!/Users/get_enrollments | 4.991168 | 5.469676 | 0.912516 |
params = {
'per_page': per_page,
'page': page,
'include_totals': str(include_totals).lower(),
'sort': sort
}
url = self._url('{}/logs'.format(user_id))
return self.client.get(url, params=params) | def get_log_events(self, user_id, page=0, per_page=50, sort=None,
include_totals=False) | Retrieve every log event for a specific user id
Args:
user_id (str): The user_id of the logs to retrieve
page (int, optional): The result's page number (zero based).
per_page (int, optional): The amount of entries per page.
Default: 50. Max value: 100
sort (str, optional): The field to use for sorting. Use field:order
where order is 1 for ascending and -1 for descending.
For example date:-1
include_totals (bool, optional): True if the query summary is
to be included in the result, False otherwise.
See: https://auth0.com/docs/api/management/v2#!/Users/get_logs_by_user | 2.312714 | 2.935224 | 0.787917 |
params = {
'stage': stage,
'fields': fields and ','.join(fields) or None,
'include_fields': str(include_fields).lower(),
'page': page,
'per_page': per_page,
'include_totals': str(include_totals).lower()
}
# since the default is True, this is here to disable the filter
if enabled is not None:
params['enabled'] = str(enabled).lower()
return self.client.get(self._url(), params=params) | def all(self, stage='login_success', enabled=True, fields=None,
include_fields=True, page=None, per_page=None, include_totals=False) | Retrieves a list of all rules.
Args:
stage (str, optional): Retrieves rules that match the execution
stage (defaults to login_success).
enabled (bool, optional): If provided, retrieves rules that match
the value, otherwise all rules are retrieved.
fields (list, optional): A list of fields to include or exclude
(depending on include_fields) from the result, empty to
retrieve all fields.
include_fields (bool, optional): True if the fields specified are
to be included in the result, False otherwise
(defaults to true).
page (int, optional): The result's page number (zero based).
per_page (int, optional): The amount of entries per page.
include_totals (bool, optional): True if the query summary is
to be included in the result, False otherwise.
See: https://auth0.com/docs/api/management/v2#!/Rules/get_rules | 2.397979 | 2.927613 | 0.81909 |
url = self._url('{}/errors'.format(id))
return self.client.get(url) | def get_failed_job(self, id) | Get failed job error details
Args:
id (str): The id of the job.
See: https://auth0.com/docs/api/management/v2#!/Jobs/get_errors | 7.995351 | 7.257582 | 1.101655 |
url = self._url('%s/results' % job_id)
return self.client.get(url) | def get_results(self, job_id) | Get results of a job
Args:
job_id (str): The ID of the job.
See: https://auth0.com/docs/api/management/v2#!/Jobs/get_results | 5.126578 | 6.217713 | 0.824512 |
return self.client.post(self._url('users-exports'), data=body) | def export_users(self, body) | Export all users to a file using a long running job.
Check job status with get(). URL pointing to the export file will be
included in the status once the job is complete.
Args:
body (dict): Please see: https://auth0.com/docs/api/management/v2#!/Jobs/post_users_exports | 8.938256 | 7.413061 | 1.205744 |
return self.client.file_post(self._url('users-imports'),
data={'connection_id': connection_id, 'upsert': str(upsert).lower()},
files={'users': file_obj}) | def import_users(self, connection_id, file_obj, upsert=False) | Imports users to a connection from a file.
Args:
connection_id (str): The connection id of the connection to which
users will be inserted.
file_obj (file): A file-like object to upload. The format for
this file is explained in: https://auth0.com/docs/bulk-import
See: https://auth0.com/docs/api/management/v2#!/Jobs/post_users_imports | 5.669092 | 6.204736 | 0.913672 |
return self.client.post(self._url('verification-email'), data=body) | def send_verification_email(self, body) | Send verification email.
Send an email to the specified user that asks them to click a link to
verify their email address.
Args:
body (dict): Please see: https://auth0.com/docs/api/v2#!/Jobs/post_verification_email | 6.419256 | 6.950091 | 0.923622 |
return self.client.post(self._url(), data=body) | def config(self, body) | Configure the email provider.
Args:
body (dict): Please see: https://auth0.com/docs/api/v2#!/Emails/post_provider | 7.274225 | 11.680678 | 0.622757 |
return self.get(
url='https://{}/userinfo'.format(self.domain),
headers={'Authorization': 'Bearer {}'.format(access_token)}
) | def userinfo(self, access_token) | Returns the user information based on the Auth0 access token.
This endpoint will work only if openid was granted as a scope for the access_token.
Args:
access_token (str): Auth0 access token (obtained during login).
Returns:
The user profile. | 4.682558 | 3.443312 | 1.3599 |
warnings.warn("/tokeninfo will be deprecated in future releases", DeprecationWarning)
return self.post(
url='https://{}/tokeninfo'.format(self.domain),
data={'id_token': jwt},
headers={'Content-Type': 'application/json'}
) | def tokeninfo(self, jwt) | Returns user profile based on the user's jwt
Validates a JSON Web Token (signature and expiration) and returns the
user information associated with the user id (sub property) of
the token.
Args:
jwt (str): User's jwt
Returns:
The user profile. | 3.978243 | 4.366209 | 0.911143 |
params = extra_params or {}
params.update({
'page': page,
'per_page': per_page,
'include_totals': str(include_totals).lower()
})
return self.client.get(self._url(), params=params) | def all(self, page=None, per_page=None, include_totals=False, extra_params=None) | Retrieves all grants.
Args:
page (int, optional): The result's page number (zero based).
per_page (int, optional): The amount of entries per page.
include_totals (bool, optional): True if the query summary is
to be included in the result, False otherwise.
extra_params (dictionary, optional): The extra parameters to add to
the request. The page, per_page, and include_totals values
specified as parameters take precedence over the ones defined here.
See: https://auth0.com/docs/api/management/v2#!/Grants/get_grants | 2.065675 | 2.952377 | 0.699665 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.