repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
adrianliaw/PyCuber
pycuber/solver/cfop/cross.py
CrossSolver._rotate
def _rotate(edges, step): """ Simulate the cube rotation by updating four edges. """ 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
python
def _rotate(edges, step): """ Simulate the cube rotation by updating four edges. """ 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", ")", ":", "step", "=", "Step", "(", "step", ")", "result", "=", "set", "(", ")", "movement", "=", "{", "\"U\"", ":", "\"RFLB\"", ",", "\"D\"", ":", "\"LFRB\"", ",", "\"R\"", ":", "\"FUBD\"", ",", "\"L\""...
Simulate the cube rotation by updating four edges.
[ "Simulate", "the", "cube", "rotation", "by", "updating", "four", "edges", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/cross.py#L22-L50
train
202,800
adrianliaw/PyCuber
pycuber/solver/cfop/cross.py
CrossSolver.cross_successors
def cross_successors(state, last_action=None): """ Successors function for solving the cross. """ 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))
python
def cross_successors(state, last_action=None): """ Successors function for solving the cross. """ 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", ")", ":", "centres", ",", "edges", "=", "state", "acts", "=", "sum", "(", "[", "[", "s", ",", "s", ".", "inverse", "(", ")", ",", "s", "*", "2", "]", "for", "s", "in", "m...
Successors function for solving the cross.
[ "Successors", "function", "for", "solving", "the", "cross", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/cross.py#L53-L63
train
202,801
adrianliaw/PyCuber
pycuber/solver/cfop/cross.py
CrossSolver.cross_goal
def cross_goal(state): """ The goal function for cross solving search. """ 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
python
def cross_goal(state): """ The goal function for cross solving search. """ 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", ")", ":", "centres", ",", "edges", "=", "state", "for", "edge", "in", "edges", ":", "if", "\"D\"", "not", "in", "edge", ".", "facings", ":", "return", "False", "if", "edge", "[", "\"D\"", "]", "!=", "centres", "[", ...
The goal function for cross solving search.
[ "The", "goal", "function", "for", "cross", "solving", "search", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/cross.py#L66-L79
train
202,802
adrianliaw/PyCuber
pycuber/solver/cfop/cross.py
CrossSolver.solve
def solve(self): """ Solve the cross. """ 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
python
def solve(self): """ Solve the cross. """ 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", ")", ":", "result", "=", "Formula", "(", "path_actions", "(", "a_star_search", "(", "(", "{", "f", ":", "self", ".", "cube", "[", "f", "]", "for", "f", "in", "\"LUFDRB\"", "}", ",", "self", ".", "cube", ".", "select_typ...
Solve the cross.
[ "Solve", "the", "cross", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/cross.py#L146-L158
train
202,803
adrianliaw/PyCuber
pycuber/solver/cfop/cross.py
CrossSolver.is_solved
def is_solved(self): """ Check if the cross of Cube is solved. """ 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)))
python
def is_solved(self): """ Check if the cross of Cube is solved. """ 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", ")", ":", "return", "self", ".", "cross_goal", "(", "(", "{", "f", ":", "self", ".", "cube", "[", "f", "]", "for", "f", "in", "\"LUFDRB\"", "}", ",", "self", ".", "cube", ".", "select_type", "(", "\"edge\"", ")", ...
Check if the cross of Cube is solved.
[ "Check", "if", "the", "cross", "of", "Cube", "is", "solved", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/cross.py#L160-L165
train
202,804
adrianliaw/PyCuber
pycuber/solver/cfop/pll.py
PLLSolver.recognise
def recognise(self): """ Recognise the PLL case of Cube. """ 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
python
def recognise(self): """ Recognise the PLL case of Cube. """ 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", ")", ":", "result", "=", "\"\"", "for", "side", "in", "\"LFRB\"", ":", "for", "square", "in", "self", ".", "cube", ".", "get_face", "(", "side", ")", "[", "0", "]", ":", "for", "_side", "in", "\"LFRB\"", ":", "if", ...
Recognise the PLL case of Cube.
[ "Recognise", "the", "PLL", "case", "of", "Cube", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/pll.py#L32-L43
train
202,805
adrianliaw/PyCuber
pycuber/solver/cfop/pll.py
PLLSolver.solve
def solve(self): """ Solve PLL of Cube. """ 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.")
python
def solve(self): """ Solve PLL of Cube. """ 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", ")", ":", "if", "not", "isinstance", "(", "self", ".", "cube", ",", "Cube", ")", ":", "raise", "ValueError", "(", "\"Use Solver.feed(cube) to feed the cube to solver.\"", ")", "for", "i", "in", "range", "(", "4", ")", ":", "rec...
Solve PLL of Cube.
[ "Solve", "PLL", "of", "Cube", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/pll.py#L45-L57
train
202,806
adrianliaw/PyCuber
pycuber/solver/cfop/pll.py
PLLSolver.is_solved
def is_solved(self): """ Check if Cube is solved. """ 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
python
def is_solved(self): """ Check if Cube is solved. """ 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", ")", ":", "for", "side", "in", "\"LUFDRB\"", ":", "sample", "=", "self", ".", "cube", "[", "side", "]", ".", "facings", "[", "side", "]", "for", "square", "in", "sum", "(", "self", ".", "cube", ".", "get_face", "(",...
Check if Cube is solved.
[ "Check", "if", "Cube", "is", "solved", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/pll.py#L59-L68
train
202,807
adrianliaw/PyCuber
pycuber/solver/cfop/oll.py
OLLSolver.recognise
def recognise(self): """ Recognise which is Cube's OLL case. """ 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
python
def recognise(self): """ Recognise which is Cube's OLL case. """ 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", ")", ":", "if", "not", "isinstance", "(", "self", ".", "cube", ",", "Cube", ")", ":", "raise", "ValueError", "(", "\"Use Solver.feed(cube) to feed the cube to solver.\"", ")", "result", "=", "\"\"", "for", "face", "in", "\"LFRB...
Recognise which is Cube's OLL case.
[ "Recognise", "which", "is", "Cube", "s", "OLL", "case", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/oll.py#L30-L43
train
202,808
adrianliaw/PyCuber
pycuber/solver/cfop/oll.py
OLLSolver.solve
def solve(self): """ Solve the OLL. Returns an Formula. """ 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]
python
def solve(self): """ Solve the OLL. Returns an Formula. """ 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", ")", ":", "if", "not", "isinstance", "(", "self", ".", "cube", ",", "Cube", ")", ":", "raise", "ValueError", "(", "\"Use Solver.feed(cube) to feed the cube to solver.\"", ")", "self", ".", "recognise", "(", ")", "self", ".", "cub...
Solve the OLL. Returns an Formula.
[ "Solve", "the", "OLL", ".", "Returns", "an", "Formula", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/oll.py#L45-L53
train
202,809
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
F2LPairSolver.feed
def feed(self, cube, pair): """ Feed Cube to the solver. """ 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
python
def feed(self, cube, pair): """ Feed Cube to the solver. """ 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", ")", ":", "self", ".", "cube", "=", "cube", "if", "pair", "not", "in", "[", "\"FR\"", ",", "\"RB\"", ",", "\"BL\"", ",", "\"LF\"", "]", ":", "pair", "=", "[", "\"FR\"", ",", "\"RB\"", ",", "...
Feed Cube to the solver.
[ "Feed", "Cube", "to", "the", "solver", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L19-L26
train
202,810
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
F2LPairSolver.estimated_position
def estimated_position(self): """ Get the estimated cubie of solved pair. """ 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))
python
def estimated_position(self): """ Get the estimated cubie of solved pair. """ 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", ")", ":", "corner", "=", "{", "\"D\"", ":", "self", ".", "cube", "[", "\"D\"", "]", "[", "\"D\"", "]", "}", "edge", "=", "{", "}", "for", "cubie", "in", "(", "corner", ",", "edge", ")", ":", "for", "face"...
Get the estimated cubie of solved pair.
[ "Get", "the", "estimated", "cubie", "of", "solved", "pair", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L44-L53
train
202,811
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
F2LPairSolver.get_slot
def get_slot(self): """ Get the slot position of this pair. """ 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))
python
def get_slot(self): """ Get the slot position of this pair. """ 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", ")", ":", "corner", ",", "edge", "=", "self", ".", "get_pair", "(", ")", "corner_slot", ",", "edge_slot", "=", "corner", ".", "location", ".", "replace", "(", "\"D\"", ",", "\"\"", ",", "1", ")", ",", "edge", ".", "l...
Get the slot position of this pair.
[ "Get", "the", "slot", "position", "of", "this", "pair", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L55-L75
train
202,812
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
F2LPairSolver.combining_goal
def combining_goal(state): """ Check if two Cubies are combined on the U face. """ ((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
python
def combining_goal(state): """ Check if two Cubies are combined on the U face. """ ((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", ")", ":", "(", "(", "corner", ",", "edge", ")", ",", "(", "L", ",", "U", ",", "F", ",", "D", ",", "R", ",", "B", ")", ")", "=", "state", "if", "\"U\"", "not", "in", "corner", "or", "\"U\"", "not", "in", ...
Check if two Cubies are combined on the U face.
[ "Check", "if", "two", "Cubies", "are", "combined", "on", "the", "U", "face", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L78-L95
train
202,813
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
F2LPairSolver._rotate
def _rotate(pair, step): """ Simulate the cube rotation by updating the pair. """ 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)
python
def _rotate(pair, step): """ Simulate the cube rotation by updating the pair. """ 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", ")", ":", "step", "=", "Step", "(", "step", ")", "movement", "=", "{", "\"U\"", ":", "\"RFLB\"", ",", "\"D\"", ":", "\"LFRB\"", ",", "\"R\"", ":", "\"FUBD\"", ",", "\"L\"", ":", "\"FDBU\"", ",", "\"F\"", ...
Simulate the cube rotation by updating the pair.
[ "Simulate", "the", "cube", "rotation", "by", "updating", "the", "pair", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L98-L132
train
202,814
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
F2LPairSolver.combining_successors
def combining_successors(state, last_action=()): """ Successors function for finding path of combining F2L pair. """ ((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))
python
def combining_successors(state, last_action=()): """ Successors function for finding path of combining F2L pair. """ ((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", "=", "(", ")", ")", ":", "(", "(", "corner", ",", "edge", ")", ",", "(", "L", ",", "U", ",", "F", ",", "D", ",", "R", ",", "B", ")", ")", "=", "state", "U_turns", "=", "[", "For...
Successors function for finding path of combining F2L pair.
[ "Successors", "function", "for", "finding", "path", "of", "combining", "F2L", "pair", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L135-L147
train
202,815
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
F2LPairSolver.combining_search
def combining_search(self): """ Searching the path for combining the pair. """ 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())
python
def combining_search(self): """ Searching the path for combining the pair. """ 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", ")", ":", "start", "=", "(", "self", ".", "get_pair", "(", ")", ",", "(", "self", ".", "cube", "[", "\"L\"", "]", ",", "self", ".", "cube", "[", "\"U\"", "]", ",", "self", ".", "cube", "[", "\"F\"", "]", ...
Searching the path for combining the pair.
[ "Searching", "the", "path", "for", "combining", "the", "pair", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L149-L167
train
202,816
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
F2LPairSolver.combining_setup
def combining_setup(self): """ Setup for some special F2L cases. """ (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())
python
def combining_setup(self): """ Setup for some special F2L cases. """ (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", ")", ":", "(", "slot_type", ",", "(", "corner_slot", ",", "edge_slot", ")", ",", "(", "corner", ",", "edge", ")", ")", "=", "self", ".", "get_slot", "(", ")", "cycle", "=", "[", "\"FR\"", ",", "\"RB\"", ",", "...
Setup for some special F2L cases.
[ "Setup", "for", "some", "special", "F2L", "cases", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L169-L194
train
202,817
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
F2LPairSolver.combine
def combine(self): """ Combine the pair. """ self.pair, setup = self.combining_setup() self.cube(setup) actual = self.combining_search() self.cube(actual) return setup + actual
python
def combine(self): """ Combine the pair. """ self.pair, setup = self.combining_setup() self.cube(setup) actual = self.combining_search() self.cube(actual) return setup + actual
[ "def", "combine", "(", "self", ")", ":", "self", ".", "pair", ",", "setup", "=", "self", ".", "combining_setup", "(", ")", "self", ".", "cube", "(", "setup", ")", "actual", "=", "self", ".", "combining_search", "(", ")", "self", ".", "cube", "(", "...
Combine the pair.
[ "Combine", "the", "pair", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L196-L204
train
202,818
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
F2LPairSolver.solve
def solve(self): """ Solve the pair. """ 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())
python
def solve(self): """ Solve the pair. """ 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", ")", ":", "cycle", "=", "[", "\"FR\"", ",", "\"RB\"", ",", "\"BL\"", ",", "\"LF\"", "]", "combine", "=", "self", ".", "combine", "(", ")", "put", "=", "Formula", "(", "Step", "(", "\"y\"", ")", "*", "cycle", ".", "ind...
Solve the pair.
[ "Solve", "the", "pair", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L206-L224
train
202,819
adrianliaw/PyCuber
pycuber/solver/cfop/f2l.py
F2LSolver.is_solved
def is_solved(self): """ Check if Cube's F2L is solved. """ 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
python
def is_solved(self): """ Check if Cube's F2L is solved. """ 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", ")", ":", "if", "self", ".", "cube", ".", "D", "==", "[", "[", "Square", "(", "self", ".", "cube", "[", "\"D\"", "]", ".", "colour", ")", "]", "*", "3", "]", "*", "3", ":", "for", "face", "in", "\"LFRB\"", ":"...
Check if Cube's F2L is solved.
[ "Check", "if", "Cube", "s", "F2L", "is", "solved", "." ]
e44b5ba48c831b964ce73d046fb813222771853f
https://github.com/adrianliaw/PyCuber/blob/e44b5ba48c831b964ce73d046fb813222771853f/pycuber/solver/cfop/f2l.py#L257-L266
train
202,820
auth0/auth0-python
auth0/v3/authentication/get_token.py
GetToken.authorization_code_pkce
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 """ 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'} )
python
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 """ 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'", ")", ":", "return", "self", ".", "post", "(", "'https://{}/oauth/token'", ".", "format", "(", ...
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
[ "Authorization", "code", "pkce", "grant" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/get_token.py#L49-L84
train
202,821
auth0/auth0-python
auth0/v3/authentication/get_token.py
GetToken.client_credentials
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 """ 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'} )
python
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 """ 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'", ")", ":", "return", "self", ".", "post", "(", "'https://{}/oauth/token'", ".", "format", "(", "self", ".", "domain"...
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
[ "Client", "credentials", "grant" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/get_token.py#L86-L118
train
202,822
auth0/auth0-python
auth0/v3/management/connections.py
Connections.get
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. """ params = {'fields': fields and ','.join(fields) or None, 'include_fields': str(include_fields).lower()} return self.client.get(self._url(id), params=params)
python
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. """ 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", ")", ":", "params", "=", "{", "'fields'", ":", "fields", "and", "','", ".", "join", "(", "fields", ")", "or", "None", ",", "'include_fields'", ":", ...
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.
[ "Retrieve", "connection", "by", "id", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/connections.py#L63-L85
train
202,823
auth0/auth0-python
auth0/v3/management/connections.py
Connections.update
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. """ return self.client.patch(self._url(id), data=body)
python
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. """ return self.client.patch(self._url(id), data=body)
[ "def", "update", "(", "self", ",", "id", ",", "body", ")", ":", "return", "self", ".", "client", ".", "patch", "(", "self", ".", "_url", "(", "id", ")", ",", "data", "=", "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.
[ "Modifies", "a", "connection", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/connections.py#L101-L115
train
202,824
auth0/auth0-python
auth0/v3/management/connections.py
Connections.create
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 """ return self.client.post(self._url(), data=body)
python
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 """ return self.client.post(self._url(), data=body)
[ "def", "create", "(", "self", ",", "body", ")", ":", "return", "self", ".", "client", ".", "post", "(", "self", ".", "_url", "(", ")", ",", "data", "=", "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
[ "Creates", "a", "new", "connection", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/connections.py#L117-L126
train
202,825
auth0/auth0-python
auth0/v3/management/connections.py
Connections.delete_user_by_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. """ return self.client.delete(self._url(id) + '/users', params={'email': email})
python
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. """ return self.client.delete(self._url(id) + '/users', params={'email': email})
[ "def", "delete_user_by_email", "(", "self", ",", "id", ",", "email", ")", ":", "return", "self", ".", "client", ".", "delete", "(", "self", ".", "_url", "(", "id", ")", "+", "'/users'", ",", "params", "=", "{", "'email'", ":", "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.
[ "Deletes", "a", "specified", "connection", "user", "by", "its", "email", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/connections.py#L128-L141
train
202,826
auth0/auth0-python
auth0/v3/management/device_credentials.py
DeviceCredentials.get
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 """ 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)
python
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 """ 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", ")", ":", "params", "=", "{", "'fields'", ":", "fields", "and", "','", ".", "join", "(", "fields", ")", "or", ...
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
[ "List", "device", "credentials", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/device_credentials.py#L27-L56
train
202,827
auth0/auth0-python
auth0/v3/management/custom_domains.py
CustomDomains.get
def get(self, id): """Retrieves custom domain. See: https://auth0.com/docs/api/management/v2#!/Custom_Domains/get_custom_domains_by_id """ url = self._url('%s' % (id)) return self.client.get(url)
python
def get(self, id): """Retrieves custom domain. See: https://auth0.com/docs/api/management/v2#!/Custom_Domains/get_custom_domains_by_id """ url = self._url('%s' % (id)) return self.client.get(url)
[ "def", "get", "(", "self", ",", "id", ")", ":", "url", "=", "self", ".", "_url", "(", "'%s'", "%", "(", "id", ")", ")", "return", "self", ".", "client", ".", "get", "(", "url", ")" ]
Retrieves custom domain. See: https://auth0.com/docs/api/management/v2#!/Custom_Domains/get_custom_domains_by_id
[ "Retrieves", "custom", "domain", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/custom_domains.py#L34-L40
train
202,828
auth0/auth0-python
auth0/v3/management/custom_domains.py
CustomDomains.delete
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 """ url = self._url('%s' % (id)) return self.client.delete(url)
python
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 """ url = self._url('%s' % (id)) return self.client.delete(url)
[ "def", "delete", "(", "self", ",", "id", ")", ":", "url", "=", "self", ".", "_url", "(", "'%s'", "%", "(", "id", ")", ")", "return", "self", ".", "client", ".", "delete", "(", "url", ")" ]
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
[ "Deletes", "a", "grant", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/custom_domains.py#L42-L52
train
202,829
auth0/auth0-python
auth0/v3/management/custom_domains.py
CustomDomains.create_new
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 """ return self.client.post(self._url(), data=body)
python
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 """ return self.client.post(self._url(), data=body)
[ "def", "create_new", "(", "self", ",", "body", ")", ":", "return", "self", ".", "client", ".", "post", "(", "self", ".", "_url", "(", ")", ",", "data", "=", "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
[ "Configure", "a", "new", "custom", "domain" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/custom_domains.py#L54-L63
train
202,830
auth0/auth0-python
auth0/v3/management/custom_domains.py
CustomDomains.verify
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 """ url = self._url('%s/verify' % (id)) return self.client.post(url)
python
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 """ url = self._url('%s/verify' % (id)) return self.client.post(url)
[ "def", "verify", "(", "self", ",", "id", ")", ":", "url", "=", "self", ".", "_url", "(", "'%s/verify'", "%", "(", "id", ")", ")", "return", "self", ".", "client", ".", "post", "(", "url", ")" ]
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
[ "Verify", "a", "custom", "domain" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/custom_domains.py#L65-L75
train
202,831
auth0/auth0-python
auth0/v3/authentication/enterprise.py
Enterprise.saml_metadata
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. """ return self.get(url='https://{}/samlp/metadata/{}'.format(self.domain, client_id))
python
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. """ return self.get(url='https://{}/samlp/metadata/{}'.format(self.domain, client_id))
[ "def", "saml_metadata", "(", "self", ",", "client_id", ")", ":", "return", "self", ".", "get", "(", "url", "=", "'https://{}/samlp/metadata/{}'", ".", "format", "(", "self", ".", "domain", ",", "client_id", ")", ")" ]
Get SAML2.0 Metadata. Args: client_id (str): Client Id of the application to get the SAML metadata for.
[ "Get", "SAML2", ".", "0", "Metadata", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/enterprise.py#L12-L20
train
202,832
auth0/auth0-python
auth0/v3/authentication/enterprise.py
Enterprise.wsfed_metadata
def wsfed_metadata(self): """Returns the WS-Federation Metadata. """ url = 'https://{}/wsfed/FederationMetadata' \ '/2007-06/FederationMetadata.xml' return self.get(url=url.format(self.domain))
python
def wsfed_metadata(self): """Returns the WS-Federation Metadata. """ url = 'https://{}/wsfed/FederationMetadata' \ '/2007-06/FederationMetadata.xml' return self.get(url=url.format(self.domain))
[ "def", "wsfed_metadata", "(", "self", ")", ":", "url", "=", "'https://{}/wsfed/FederationMetadata'", "'/2007-06/FederationMetadata.xml'", "return", "self", ".", "get", "(", "url", "=", "url", ".", "format", "(", "self", ".", "domain", ")", ")" ]
Returns the WS-Federation Metadata.
[ "Returns", "the", "WS", "-", "Federation", "Metadata", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/enterprise.py#L22-L29
train
202,833
auth0/auth0-python
auth0/v3/management/clients.py
Clients.all
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 """ 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)
python
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 """ 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", ")", ":", "params", "=", "extra_params", "or", "{", "}", "params", "[...
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
[ "Retrieves", "a", "list", "of", "all", "the", "applications", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/clients.py#L27-L58
train
202,834
auth0/auth0-python
auth0/v3/management/clients.py
Clients.rotate_secret
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 """ params = {'id': id } url = self._url('%s/rotate-secret' % id) return self.client.get(url, params=params)
python
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 """ params = {'id': id } url = self._url('%s/rotate-secret' % id) return self.client.get(url, params=params)
[ "def", "rotate_secret", "(", "self", ",", "id", ")", ":", "params", "=", "{", "'id'", ":", "id", "}", "url", "=", "self", ".", "_url", "(", "'%s/rotate-secret'", "%", "id", ")", "return", "self", ".", "client", ".", "get", "(", "url", ",", "params"...
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
[ "Rotate", "a", "client", "secret", ".", "The", "generated", "secret", "is", "NOT", "base64", "encoded", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/clients.py#L122-L135
train
202,835
auth0/auth0-python
auth0/v3/authentication/passwordless.py
Passwordless.email
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. """ 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'} )
python
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. """ 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", ")", ":", "return", "self", ".", "post", "(", "'https://{}/passwordless/start'", ".", "format", "(", "self", ".", "domain", ")", ","...
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.
[ "Start", "flow", "sending", "an", "email", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/passwordless.py#L12-L46
train
202,836
auth0/auth0-python
auth0/v3/authentication/passwordless.py
Passwordless.sms
def sms(self, client_id, phone_number): """Start flow sending a SMS message. """ 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'} )
python
def sms(self, client_id, phone_number): """Start flow sending a SMS message. """ 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", ")", ":", "return", "self", ".", "post", "(", "'https://{}/passwordless/start'", ".", "format", "(", "self", ".", "domain", ")", ",", "data", "=", "{", "'client_id'", ":", "client_id", ",", ...
Start flow sending a SMS message.
[ "Start", "flow", "sending", "a", "SMS", "message", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/passwordless.py#L48-L60
train
202,837
auth0/auth0-python
auth0/v3/management/resource_servers.py
ResourceServers.get_all
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 """ params = { 'page': page, 'per_page': per_page, 'include_totals': str(include_totals).lower() } return self.client.get(self._url(), params=params)
python
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 """ 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", ")", ":", "params", "=", "{", "'page'", ":", "page", ",", "'per_page'", ":", "per_page", ",", "'include_totals'", ":", "str", "(...
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
[ "Retrieves", "all", "resource", "servers" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/resource_servers.py#L37-L57
train
202,838
auth0/auth0-python
auth0/v3/management/user_blocks.py
UserBlocks.get_by_identifier
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 """ params = {'identifier': identifier} return self.client.get(self._url(), params=params)
python
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 """ params = {'identifier': identifier} return self.client.get(self._url(), params=params)
[ "def", "get_by_identifier", "(", "self", ",", "identifier", ")", ":", "params", "=", "{", "'identifier'", ":", "identifier", "}", "return", "self", ".", "client", ".", "get", "(", "self", ".", "_url", "(", ")", ",", "params", "=", "params", ")" ]
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
[ "Gets", "blocks", "by", "identifier" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/user_blocks.py#L27-L38
train
202,839
auth0/auth0-python
auth0/v3/management/user_blocks.py
UserBlocks.unblock_by_identifier
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 """ params = {'identifier': identifier} return self.client.delete(self._url(), params=params)
python
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 """ params = {'identifier': identifier} return self.client.delete(self._url(), params=params)
[ "def", "unblock_by_identifier", "(", "self", ",", "identifier", ")", ":", "params", "=", "{", "'identifier'", ":", "identifier", "}", "return", "self", ".", "client", ".", "delete", "(", "self", ".", "_url", "(", ")", ",", "params", "=", "params", ")" ]
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
[ "Unblocks", "by", "identifier" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/user_blocks.py#L40-L51
train
202,840
auth0/auth0-python
auth0/v3/authentication/delegated.py
Delegated.get_token
def get_token(self, client_id, target, api_type, grant_type, id_token=None, refresh_token=None, scope='openid'): """Obtain a delegation token. """ 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 )
python
def get_token(self, client_id, target, api_type, grant_type, id_token=None, refresh_token=None, scope='openid'): """Obtain a delegation token. """ 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'", ")", ":", "if", "id_token", "and", "refresh_token", ":", ...
Obtain a delegation token.
[ "Obtain", "a", "delegation", "token", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/delegated.py#L12-L42
train
202,841
auth0/auth0-python
auth0/v3/management/guardian.py
Guardian.update_templates
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 """ return self.client.put(self._url('factors/sms/templates'), data=body)
python
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 """ return self.client.put(self._url('factors/sms/templates'), data=body)
[ "def", "update_templates", "(", "self", ",", "body", ")", ":", "return", "self", ".", "client", ".", "put", "(", "self", ".", "_url", "(", "'factors/sms/templates'", ")", ",", "data", "=", "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
[ "Update", "enrollment", "and", "verification", "SMS", "templates", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/guardian.py#L48-L58
train
202,842
auth0/auth0-python
auth0/v3/management/guardian.py
Guardian.get_enrollment
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 """ url = self._url('enrollments/{}'.format(id)) return self.client.get(url)
python
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 """ url = self._url('enrollments/{}'.format(id)) return self.client.get(url)
[ "def", "get_enrollment", "(", "self", ",", "id", ")", ":", "url", "=", "self", ".", "_url", "(", "'enrollments/{}'", ".", "format", "(", "id", ")", ")", "return", "self", ".", "client", ".", "get", "(", "url", ")" ]
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
[ "Retrieves", "an", "enrollment", ".", "Useful", "to", "check", "its", "type", "and", "related", "metadata", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/guardian.py#L72-L83
train
202,843
auth0/auth0-python
auth0/v3/management/guardian.py
Guardian.delete_enrollment
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 """ url = self._url('enrollments/{}'.format(id)) return self.client.delete(url)
python
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 """ url = self._url('enrollments/{}'.format(id)) return self.client.delete(url)
[ "def", "delete_enrollment", "(", "self", ",", "id", ")", ":", "url", "=", "self", ".", "_url", "(", "'enrollments/{}'", ".", "format", "(", "id", ")", ")", "return", "self", ".", "client", ".", "delete", "(", "url", ")" ]
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
[ "Deletes", "an", "enrollment", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/guardian.py#L85-L97
train
202,844
auth0/auth0-python
auth0/v3/management/guardian.py
Guardian.create_enrollment_ticket
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 """ return self.client.post(self._url('enrollments/ticket'), data=body)
python
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 """ return self.client.post(self._url('enrollments/ticket'), data=body)
[ "def", "create_enrollment_ticket", "(", "self", ",", "body", ")", ":", "return", "self", ".", "client", ".", "post", "(", "self", ".", "_url", "(", "'enrollments/ticket'", ")", ",", "data", "=", "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
[ "Creates", "an", "enrollment", "ticket", "for", "user_id" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/guardian.py#L99-L109
train
202,845
auth0/auth0-python
auth0/v3/management/guardian.py
Guardian.get_factor_providers
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 """ url = self._url('factors/{}/providers/{}'.format(factor_name, name)) return self.client.get(url)
python
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 """ url = self._url('factors/{}/providers/{}'.format(factor_name, name)) return self.client.get(url)
[ "def", "get_factor_providers", "(", "self", ",", "factor_name", ",", "name", ")", ":", "url", "=", "self", ".", "_url", "(", "'factors/{}/providers/{}'", ".", "format", "(", "factor_name", ",", "name", ")", ")", "return", "self", ".", "client", ".", "get",...
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
[ "Get", "Guardian", "SNS", "or", "SMS", "factor", "providers", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/guardian.py#L111-L124
train
202,846
auth0/auth0-python
auth0/v3/management/guardian.py
Guardian.update_factor_providers
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 """ url = self._url('factors/{}/providers/{}'.format(factor_name, name)) return self.client.put(url, data=body)
python
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 """ 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", ")", ":", "url", "=", "self", ".", "_url", "(", "'factors/{}/providers/{}'", ".", "format", "(", "factor_name", ",", "name", ")", ")", "return", "self", ".", "clie...
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
[ "Get", "Guardian", "factor", "providers", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/guardian.py#L126-L138
train
202,847
auth0/auth0-python
auth0/v3/authentication/revoke_token.py
RevokeToken.revoke_refresh_token
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 """ body = { 'client_id': client_id, 'token': token, 'client_secret': client_secret } return self.post( 'https://{}/oauth/revoke'.format(self.domain), data=body)
python
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 """ 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", ")", ":", "body", "=", "{", "'client_id'", ":", "client_id", ",", "'token'", ":", "token", ",", "'client_secret'", ":", "client_secret", "}", "retu...
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
[ "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", "....
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/revoke_token.py#L12-L37
train
202,848
auth0/auth0-python
auth0/v3/management/rules_configs.py
RulesConfigs.unset
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 """ params = { 'key': key } return self.client.delete(self._url(), params=params)
python
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 """ params = { 'key': key } return self.client.delete(self._url(), params=params)
[ "def", "unset", "(", "self", ",", "key", ")", ":", "params", "=", "{", "'key'", ":", "key", "}", "return", "self", ".", "client", ".", "delete", "(", "self", ".", "_url", "(", ")", ",", "params", "=", "params", ")" ]
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
[ "Removes", "the", "rules", "config", "for", "a", "given", "key", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/rules_configs.py#L34-L45
train
202,849
auth0/auth0-python
auth0/v3/management/rules_configs.py
RulesConfigs.set
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 """ url = self._url('{}'.format(key)) body = {'value': value} return self.client.put(url, data=body)
python
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 """ url = self._url('{}'.format(key)) body = {'value': value} return self.client.put(url, data=body)
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "url", "=", "self", ".", "_url", "(", "'{}'", ".", "format", "(", "key", ")", ")", "body", "=", "{", "'value'", ":", "value", "}", "return", "self", ".", "client", ".", "put", "(", ...
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
[ "Sets", "the", "rules", "config", "for", "a", "given", "key", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/rules_configs.py#L47-L59
train
202,850
auth0/auth0-python
auth0/v3/management/stats.py
Stats.daily_stats
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 """ return self.client.get(self._url('daily'), params={'from': from_date, 'to': to_date})
python
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 """ return self.client.get(self._url('daily'), params={'from': from_date, 'to': to_date})
[ "def", "daily_stats", "(", "self", ",", "from_date", "=", "None", ",", "to_date", "=", "None", ")", ":", "return", "self", ".", "client", ".", "get", "(", "self", ".", "_url", "(", "'daily'", ")", ",", "params", "=", "{", "'from'", ":", "from_date", ...
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
[ "Gets", "the", "daily", "stats", "for", "a", "particular", "period", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/stats.py#L34-L48
train
202,851
auth0/auth0-python
auth0/v3/management/tickets.py
Tickets.create_email_verification
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 """ return self.client.post(self._url('email-verification'), data=body)
python
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 """ return self.client.post(self._url('email-verification'), data=body)
[ "def", "create_email_verification", "(", "self", ",", "body", ")", ":", "return", "self", ".", "client", ".", "post", "(", "self", ".", "_url", "(", "'email-verification'", ")", ",", "data", "=", "body", ")" ]
Create an email verification ticket. Args: body (dict): Please see: https://auth0.com/docs/api/v2#!/Tickets/post_email_verification
[ "Create", "an", "email", "verification", "ticket", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/tickets.py#L24-L30
train
202,852
auth0/auth0-python
auth0/v3/management/tickets.py
Tickets.create_pswd_change
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 """ return self.client.post(self._url('password-change'), data=body)
python
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 """ return self.client.post(self._url('password-change'), data=body)
[ "def", "create_pswd_change", "(", "self", ",", "body", ")", ":", "return", "self", ".", "client", ".", "post", "(", "self", ".", "_url", "(", "'password-change'", ")", ",", "data", "=", "body", ")" ]
Create password change ticket. Args: body (dict): Please see: https://auth0.com/docs/api/v2#!/Tickets/post_password_change
[ "Create", "password", "change", "ticket", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/tickets.py#L32-L38
train
202,853
auth0/auth0-python
auth0/v3/management/logs.py
Logs.search
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 """ 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)
python
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 """ 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", "=", "N...
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
[ "Search", "log", "events", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/logs.py#L27-L71
train
202,854
auth0/auth0-python
auth0/v3/management/client_grants.py
ClientGrants.all
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 """ 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)
python
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 """ 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", ")", ":", "params", "=", "{", "'audience'", ":", "audience", ",", "'p...
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
[ "Retrieves", "all", "client", "grants", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/client_grants.py#L27-L54
train
202,855
auth0/auth0-python
auth0/v3/authentication/social.py
Social.login
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. """ 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'} )
python
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. """ 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'", ")", ":", "return", "self", ".", "post", "(", "'https://{}/oauth/access_token'", ".", "format", "(", "self", ".", "domain", ")", ",", "dat...
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.
[ "Login", "using", "a", "social", "provider", "s", "access", "token" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/social.py#L12-L40
train
202,856
auth0/auth0-python
auth0/v3/management/blacklists.py
Blacklists.get
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 """ params = { 'aud': aud } return self.client.get(self.url, params=params)
python
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 """ params = { 'aud': aud } return self.client.get(self.url, params=params)
[ "def", "get", "(", "self", ",", "aud", "=", "None", ")", ":", "params", "=", "{", "'aud'", ":", "aud", "}", "return", "self", ".", "client", ".", "get", "(", "self", ".", "url", ",", "params", "=", "params", ")" ]
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
[ "Retrieves", "the", "jti", "and", "aud", "of", "all", "tokens", "in", "the", "blacklist", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/blacklists.py#L20-L35
train
202,857
auth0/auth0-python
auth0/v3/management/blacklists.py
Blacklists.create
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 """ return self.client.post(self.url, data={'jti': jti, 'aud': aud})
python
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 """ return self.client.post(self.url, data={'jti': jti, 'aud': aud})
[ "def", "create", "(", "self", ",", "jti", ",", "aud", "=", "''", ")", ":", "return", "self", ".", "client", ".", "post", "(", "self", ".", "url", ",", "data", "=", "{", "'jti'", ":", "jti", ",", "'aud'", ":", "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
[ "Adds", "a", "token", "to", "the", "blacklist", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/blacklists.py#L37-L49
train
202,858
auth0/auth0-python
auth0/v3/management/users.py
Users.list
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 """ 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)
python
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 """ 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", "=...
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
[ "List", "or", "search", "users", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/users.py#L27-L70
train
202,859
auth0/auth0-python
auth0/v3/management/users.py
Users.delete_multifactor
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 """ url = self._url('{}/multifactor/{}'.format(id, provider)) return self.client.delete(url)
python
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 """ url = self._url('{}/multifactor/{}'.format(id, provider)) return self.client.delete(url)
[ "def", "delete_multifactor", "(", "self", ",", "id", ",", "provider", ")", ":", "url", "=", "self", ".", "_url", "(", "'{}/multifactor/{}'", ".", "format", "(", "id", ",", "provider", ")", ")", "return", "self", ".", "client", ".", "delete", "(", "url"...
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
[ "Delete", "a", "user", "s", "multifactor", "provider", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/users.py#L129-L141
train
202,860
auth0/auth0-python
auth0/v3/management/users.py
Users.unlink_user_account
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 """ url = self._url('{}/identities/{}/{}'.format(id, provider, user_id)) return self.client.delete(url)
python
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 """ url = self._url('{}/identities/{}/{}'.format(id, provider, user_id)) return self.client.delete(url)
[ "def", "unlink_user_account", "(", "self", ",", "id", ",", "provider", ",", "user_id", ")", ":", "url", "=", "self", ".", "_url", "(", "'{}/identities/{}/{}'", ".", "format", "(", "id", ",", "provider", ",", "user_id", ")", ")", "return", "self", ".", ...
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
[ "Unlink", "a", "user", "account" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/users.py#L143-L156
train
202,861
auth0/auth0-python
auth0/v3/management/users.py
Users.link_user_account
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 """ url = self._url('{}/identities'.format(user_id)) return self.client.post(url, data=body)
python
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 """ url = self._url('{}/identities'.format(user_id)) return self.client.post(url, data=body)
[ "def", "link_user_account", "(", "self", ",", "user_id", ",", "body", ")", ":", "url", "=", "self", ".", "_url", "(", "'{}/identities'", ".", "format", "(", "user_id", ")", ")", "return", "self", ".", "client", ".", "post", "(", "url", ",", "data", "...
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
[ "Link", "user", "accounts", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/users.py#L158-L171
train
202,862
auth0/auth0-python
auth0/v3/management/users.py
Users.regenerate_recovery_code
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 """ url = self._url('{}/recovery-code-regeneration'.format(user_id)) return self.client.post(url)
python
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 """ url = self._url('{}/recovery-code-regeneration'.format(user_id)) return self.client.post(url)
[ "def", "regenerate_recovery_code", "(", "self", ",", "user_id", ")", ":", "url", "=", "self", ".", "_url", "(", "'{}/recovery-code-regeneration'", ".", "format", "(", "user_id", ")", ")", "return", "self", ".", "client", ".", "post", "(", "url", ")" ]
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
[ "Removes", "the", "current", "recovery", "token", "generates", "and", "returns", "a", "new", "one" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/users.py#L173-L182
train
202,863
auth0/auth0-python
auth0/v3/management/users.py
Users.get_guardian_enrollments
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 """ url = self._url('{}/enrollments'.format(user_id)) return self.client.get(url)
python
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 """ url = self._url('{}/enrollments'.format(user_id)) return self.client.get(url)
[ "def", "get_guardian_enrollments", "(", "self", ",", "user_id", ")", ":", "url", "=", "self", ".", "_url", "(", "'{}/enrollments'", ".", "format", "(", "user_id", ")", ")", "return", "self", ".", "client", ".", "get", "(", "url", ")" ]
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
[ "Retrieves", "all", "Guardian", "enrollments", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/users.py#L184-L193
train
202,864
auth0/auth0-python
auth0/v3/management/users.py
Users.get_log_events
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 """ 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)
python
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 """ 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", ")", ":", "params", "=", "{", "'per_page'", ":", "per_page", ",", "'page'", ":", "...
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
[ "Retrieve", "every", "log", "event", "for", "a", "specific", "user", "id" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/users.py#L195-L225
train
202,865
auth0/auth0-python
auth0/v3/management/rules.py
Rules.all
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 """ 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)
python
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 """ 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
[ "Retrieves", "a", "list", "of", "all", "rules", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/rules.py#L27-L69
train
202,866
auth0/auth0-python
auth0/v3/management/jobs.py
Jobs.get_failed_job
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 """ url = self._url('{}/errors'.format(id)) return self.client.get(url)
python
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 """ url = self._url('{}/errors'.format(id)) return self.client.get(url)
[ "def", "get_failed_job", "(", "self", ",", "id", ")", ":", "url", "=", "self", ".", "_url", "(", "'{}/errors'", ".", "format", "(", "id", ")", ")", "return", "self", ".", "client", ".", "get", "(", "url", ")" ]
Get failed job error details Args: id (str): The id of the job. See: https://auth0.com/docs/api/management/v2#!/Jobs/get_errors
[ "Get", "failed", "job", "error", "details" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/jobs.py#L37-L46
train
202,867
auth0/auth0-python
auth0/v3/management/jobs.py
Jobs.get_results
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 """ url = self._url('%s/results' % job_id) return self.client.get(url)
python
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 """ url = self._url('%s/results' % job_id) return self.client.get(url)
[ "def", "get_results", "(", "self", ",", "job_id", ")", ":", "url", "=", "self", ".", "_url", "(", "'%s/results'", "%", "job_id", ")", "return", "self", ".", "client", ".", "get", "(", "url", ")" ]
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
[ "Get", "results", "of", "a", "job" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/jobs.py#L48-L57
train
202,868
auth0/auth0-python
auth0/v3/management/jobs.py
Jobs.export_users
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 """ return self.client.post(self._url('users-exports'), data=body)
python
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 """ return self.client.post(self._url('users-exports'), data=body)
[ "def", "export_users", "(", "self", ",", "body", ")", ":", "return", "self", ".", "client", ".", "post", "(", "self", ".", "_url", "(", "'users-exports'", ")", ",", "data", "=", "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
[ "Export", "all", "users", "to", "a", "file", "using", "a", "long", "running", "job", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/jobs.py#L59-L68
train
202,869
auth0/auth0-python
auth0/v3/management/jobs.py
Jobs.import_users
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 """ return self.client.file_post(self._url('users-imports'), data={'connection_id': connection_id, 'upsert': str(upsert).lower()}, files={'users': file_obj})
python
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 """ 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", ")", ":", "return", "self", ".", "client", ".", "file_post", "(", "self", ".", "_url", "(", "'users-imports'", ")", ",", "data", "=", "{", "'connectio...
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
[ "Imports", "users", "to", "a", "connection", "from", "a", "file", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/jobs.py#L70-L84
train
202,870
auth0/auth0-python
auth0/v3/management/jobs.py
Jobs.send_verification_email
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 """ return self.client.post(self._url('verification-email'), data=body)
python
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 """ return self.client.post(self._url('verification-email'), data=body)
[ "def", "send_verification_email", "(", "self", ",", "body", ")", ":", "return", "self", ".", "client", ".", "post", "(", "self", ".", "_url", "(", "'verification-email'", ")", ",", "data", "=", "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
[ "Send", "verification", "email", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/jobs.py#L86-L95
train
202,871
auth0/auth0-python
auth0/v3/management/emails.py
Emails.config
def config(self, body): """Configure the email provider. Args: body (dict): Please see: https://auth0.com/docs/api/v2#!/Emails/post_provider """ return self.client.post(self._url(), data=body)
python
def config(self, body): """Configure the email provider. Args: body (dict): Please see: https://auth0.com/docs/api/v2#!/Emails/post_provider """ return self.client.post(self._url(), data=body)
[ "def", "config", "(", "self", ",", "body", ")", ":", "return", "self", ".", "client", ".", "post", "(", "self", ".", "_url", "(", ")", ",", "data", "=", "body", ")" ]
Configure the email provider. Args: body (dict): Please see: https://auth0.com/docs/api/v2#!/Emails/post_provider
[ "Configure", "the", "email", "provider", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/emails.py#L45-L51
train
202,872
auth0/auth0-python
auth0/v3/authentication/users.py
Users.userinfo
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. """ return self.get( url='https://{}/userinfo'.format(self.domain), headers={'Authorization': 'Bearer {}'.format(access_token)} )
python
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. """ return self.get( url='https://{}/userinfo'.format(self.domain), headers={'Authorization': 'Bearer {}'.format(access_token)} )
[ "def", "userinfo", "(", "self", ",", "access_token", ")", ":", "return", "self", ".", "get", "(", "url", "=", "'https://{}/userinfo'", ".", "format", "(", "self", ".", "domain", ")", ",", "headers", "=", "{", "'Authorization'", ":", "'Bearer {}'", ".", "...
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.
[ "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", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/users.py#L13-L28
train
202,873
auth0/auth0-python
auth0/v3/authentication/users.py
Users.tokeninfo
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. """ 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'} )
python
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. """ 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", ")", ":", "warnings", ".", "warn", "(", "\"/tokeninfo will be deprecated in future releases\"", ",", "DeprecationWarning", ")", "return", "self", ".", "post", "(", "url", "=", "'https://{}/tokeninfo'", ".", "format", "(...
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.
[ "Returns", "user", "profile", "based", "on", "the", "user", "s", "jwt" ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/users.py#L30-L49
train
202,874
auth0/auth0-python
auth0/v3/management/grants.py
Grants.all
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 """ 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)
python
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 """ 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", ")", ":", "params", "=", "extra_params", "or", "{", "}", "params", ".", "update", "(", "{", "'pa...
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
[ "Retrieves", "all", "grants", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/grants.py#L27-L51
train
202,875
auth0/auth0-python
auth0/v3/authentication/database.py
Database.change_password
def change_password(self, client_id, email, connection, password=None): """Asks to change a password for a given user. """ return self.post( 'https://{}/dbconnections/change_password'.format(self.domain), data={ 'client_id': client_id, 'email': email, 'password': password, 'connection': connection, }, headers={'Content-Type': 'application/json'} )
python
def change_password(self, client_id, email, connection, password=None): """Asks to change a password for a given user. """ return self.post( 'https://{}/dbconnections/change_password'.format(self.domain), data={ 'client_id': client_id, 'email': email, 'password': password, 'connection': connection, }, headers={'Content-Type': 'application/json'} )
[ "def", "change_password", "(", "self", ",", "client_id", ",", "email", ",", "connection", ",", "password", "=", "None", ")", ":", "return", "self", ".", "post", "(", "'https://{}/dbconnections/change_password'", ".", "format", "(", "self", ".", "domain", ")", ...
Asks to change a password for a given user.
[ "Asks", "to", "change", "a", "password", "for", "a", "given", "user", "." ]
34adad3f342226aaaa6071387fa405ab840e5c02
https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/database.py#L74-L87
train
202,876
latchset/jwcrypto
jwcrypto/jwa.py
_AesCbcHmacSha2.encrypt
def encrypt(self, k, a, m): """ Encrypt according to the selected encryption and hashing functions. :param k: Encryption key (optional) :param a: Additional Authentication Data :param m: Plaintext Returns a dictionary with the computed data. """ hkey = k[:_inbytes(self.keysize)] ekey = k[_inbytes(self.keysize):] # encrypt iv = _randombits(self.blocksize) cipher = Cipher(algorithms.AES(ekey), modes.CBC(iv), backend=self.backend) encryptor = cipher.encryptor() padder = PKCS7(self.blocksize).padder() padded_data = padder.update(m) + padder.finalize() e = encryptor.update(padded_data) + encryptor.finalize() # mac t = self._mac(hkey, a, iv, e) return (iv, e, t)
python
def encrypt(self, k, a, m): """ Encrypt according to the selected encryption and hashing functions. :param k: Encryption key (optional) :param a: Additional Authentication Data :param m: Plaintext Returns a dictionary with the computed data. """ hkey = k[:_inbytes(self.keysize)] ekey = k[_inbytes(self.keysize):] # encrypt iv = _randombits(self.blocksize) cipher = Cipher(algorithms.AES(ekey), modes.CBC(iv), backend=self.backend) encryptor = cipher.encryptor() padder = PKCS7(self.blocksize).padder() padded_data = padder.update(m) + padder.finalize() e = encryptor.update(padded_data) + encryptor.finalize() # mac t = self._mac(hkey, a, iv, e) return (iv, e, t)
[ "def", "encrypt", "(", "self", ",", "k", ",", "a", ",", "m", ")", ":", "hkey", "=", "k", "[", ":", "_inbytes", "(", "self", ".", "keysize", ")", "]", "ekey", "=", "k", "[", "_inbytes", "(", "self", ".", "keysize", ")", ":", "]", "# encrypt", ...
Encrypt according to the selected encryption and hashing functions. :param k: Encryption key (optional) :param a: Additional Authentication Data :param m: Plaintext Returns a dictionary with the computed data.
[ "Encrypt", "according", "to", "the", "selected", "encryption", "and", "hashing", "functions", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwa.py#L861-L886
train
202,877
latchset/jwcrypto
jwcrypto/jwa.py
_AesGcm.encrypt
def encrypt(self, k, a, m): """ Encrypt accoriding to the selected encryption and hashing functions. :param k: Encryption key (optional) :param a: Additional Authentication Data :param m: Plaintext Returns a dictionary with the computed data. """ iv = _randombits(96) cipher = Cipher(algorithms.AES(k), modes.GCM(iv), backend=self.backend) encryptor = cipher.encryptor() encryptor.authenticate_additional_data(a) e = encryptor.update(m) + encryptor.finalize() return (iv, e, encryptor.tag)
python
def encrypt(self, k, a, m): """ Encrypt accoriding to the selected encryption and hashing functions. :param k: Encryption key (optional) :param a: Additional Authentication Data :param m: Plaintext Returns a dictionary with the computed data. """ iv = _randombits(96) cipher = Cipher(algorithms.AES(k), modes.GCM(iv), backend=self.backend) encryptor = cipher.encryptor() encryptor.authenticate_additional_data(a) e = encryptor.update(m) + encryptor.finalize() return (iv, e, encryptor.tag)
[ "def", "encrypt", "(", "self", ",", "k", ",", "a", ",", "m", ")", ":", "iv", "=", "_randombits", "(", "96", ")", "cipher", "=", "Cipher", "(", "algorithms", ".", "AES", "(", "k", ")", ",", "modes", ".", "GCM", "(", "iv", ")", ",", "backend", ...
Encrypt accoriding to the selected encryption and hashing functions. :param k: Encryption key (optional) :param a: Additional Authentication Data :param m: Plaintext Returns a dictionary with the computed data.
[ "Encrypt", "accoriding", "to", "the", "selected", "encryption", "and", "hashing", "functions", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwa.py#L960-L977
train
202,878
latchset/jwcrypto
jwcrypto/jwk.py
JWK.from_json
def from_json(cls, key): """Creates a RFC 7517 JWK from the standard JSON format. :param key: The RFC 7517 representation of a JWK. """ obj = cls() try: jkey = json_decode(key) except Exception as e: # pylint: disable=broad-except raise InvalidJWKValue(e) obj.import_key(**jkey) return obj
python
def from_json(cls, key): """Creates a RFC 7517 JWK from the standard JSON format. :param key: The RFC 7517 representation of a JWK. """ obj = cls() try: jkey = json_decode(key) except Exception as e: # pylint: disable=broad-except raise InvalidJWKValue(e) obj.import_key(**jkey) return obj
[ "def", "from_json", "(", "cls", ",", "key", ")", ":", "obj", "=", "cls", "(", ")", "try", ":", "jkey", "=", "json_decode", "(", "key", ")", "except", "Exception", "as", "e", ":", "# pylint: disable=broad-except", "raise", "InvalidJWKValue", "(", "e", ")"...
Creates a RFC 7517 JWK from the standard JSON format. :param key: The RFC 7517 representation of a JWK.
[ "Creates", "a", "RFC", "7517", "JWK", "from", "the", "standard", "JSON", "format", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwk.py#L490-L501
train
202,879
latchset/jwcrypto
jwcrypto/jwk.py
JWK.export
def export(self, private_key=True): """Exports the key in the standard JSON format. Exports the key regardless of type, if private_key is False and the key is_symmetric an exceptionis raised. :param private_key(bool): Whether to export the private key. Defaults to True. """ if private_key is True: # Use _export_all for backwards compatibility, as this # function allows to export symmetrict keys too return self._export_all() else: return self.export_public()
python
def export(self, private_key=True): """Exports the key in the standard JSON format. Exports the key regardless of type, if private_key is False and the key is_symmetric an exceptionis raised. :param private_key(bool): Whether to export the private key. Defaults to True. """ if private_key is True: # Use _export_all for backwards compatibility, as this # function allows to export symmetrict keys too return self._export_all() else: return self.export_public()
[ "def", "export", "(", "self", ",", "private_key", "=", "True", ")", ":", "if", "private_key", "is", "True", ":", "# Use _export_all for backwards compatibility, as this", "# function allows to export symmetrict keys too", "return", "self", ".", "_export_all", "(", ")", ...
Exports the key in the standard JSON format. Exports the key regardless of type, if private_key is False and the key is_symmetric an exceptionis raised. :param private_key(bool): Whether to export the private key. Defaults to True.
[ "Exports", "the", "key", "in", "the", "standard", "JSON", "format", ".", "Exports", "the", "key", "regardless", "of", "type", "if", "private_key", "is", "False", "and", "the", "key", "is_symmetric", "an", "exceptionis", "raised", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwk.py#L503-L516
train
202,880
latchset/jwcrypto
jwcrypto/jwk.py
JWK.has_public
def has_public(self): """Whether this JWK has an asymmetric Public key.""" if self.is_symmetric: return False reg = JWKValuesRegistry[self._params['kty']] for value in reg: if reg[value].public and value in self._key: return True
python
def has_public(self): """Whether this JWK has an asymmetric Public key.""" if self.is_symmetric: return False reg = JWKValuesRegistry[self._params['kty']] for value in reg: if reg[value].public and value in self._key: return True
[ "def", "has_public", "(", "self", ")", ":", "if", "self", ".", "is_symmetric", ":", "return", "False", "reg", "=", "JWKValuesRegistry", "[", "self", ".", "_params", "[", "'kty'", "]", "]", "for", "value", "in", "reg", ":", "if", "reg", "[", "value", ...
Whether this JWK has an asymmetric Public key.
[ "Whether", "this", "JWK", "has", "an", "asymmetric", "Public", "key", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwk.py#L566-L573
train
202,881
latchset/jwcrypto
jwcrypto/jwk.py
JWK.get_curve
def get_curve(self, arg): """Gets the Elliptic Curve associated with the key. :param arg: an optional curve name :raises InvalidJWKType: the key is not an EC or OKP key. :raises InvalidJWKValue: if the curve names is invalid. """ k = self._key if self._params['kty'] not in ['EC', 'OKP']: raise InvalidJWKType('Not an EC or OKP key') if arg and k['crv'] != arg: raise InvalidJWKValue('Curve requested is "%s", but ' 'key curve is "%s"' % (arg, k['crv'])) return self._get_curve_by_name(k['crv'])
python
def get_curve(self, arg): """Gets the Elliptic Curve associated with the key. :param arg: an optional curve name :raises InvalidJWKType: the key is not an EC or OKP key. :raises InvalidJWKValue: if the curve names is invalid. """ k = self._key if self._params['kty'] not in ['EC', 'OKP']: raise InvalidJWKType('Not an EC or OKP key') if arg and k['crv'] != arg: raise InvalidJWKValue('Curve requested is "%s", but ' 'key curve is "%s"' % (arg, k['crv'])) return self._get_curve_by_name(k['crv'])
[ "def", "get_curve", "(", "self", ",", "arg", ")", ":", "k", "=", "self", ".", "_key", "if", "self", ".", "_params", "[", "'kty'", "]", "not", "in", "[", "'EC'", ",", "'OKP'", "]", ":", "raise", "InvalidJWKType", "(", "'Not an EC or OKP key'", ")", "i...
Gets the Elliptic Curve associated with the key. :param arg: an optional curve name :raises InvalidJWKType: the key is not an EC or OKP key. :raises InvalidJWKValue: if the curve names is invalid.
[ "Gets", "the", "Elliptic", "Curve", "associated", "with", "the", "key", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwk.py#L610-L625
train
202,882
latchset/jwcrypto
jwcrypto/jwk.py
JWK.get_op_key
def get_op_key(self, operation=None, arg=None): """Get the key object associated to the requested opration. For example the public RSA key for the 'verify' operation or the private EC key for the 'decrypt' operation. :param operation: The requested operation. The valid set of operations is availble in the :data:`JWKOperationsRegistry` registry. :param arg: an optional, context specific, argument For example a curve name. :raises InvalidJWKOperation: if the operation is unknown or not permitted with this key. :raises InvalidJWKUsage: if the use constraints do not permit the operation. """ validops = self._params.get('key_ops', list(JWKOperationsRegistry.keys())) if validops is not list: validops = [validops] if operation is None: if self._params['kty'] == 'oct': return self._key['k'] raise InvalidJWKOperation(operation, validops) elif operation == 'sign': self._check_constraints('sig', operation) return self._get_private_key(arg) elif operation == 'verify': self._check_constraints('sig', operation) return self._get_public_key(arg) elif operation == 'encrypt' or operation == 'wrapKey': self._check_constraints('enc', operation) return self._get_public_key(arg) elif operation == 'decrypt' or operation == 'unwrapKey': self._check_constraints('enc', operation) return self._get_private_key(arg) else: raise NotImplementedError
python
def get_op_key(self, operation=None, arg=None): """Get the key object associated to the requested opration. For example the public RSA key for the 'verify' operation or the private EC key for the 'decrypt' operation. :param operation: The requested operation. The valid set of operations is availble in the :data:`JWKOperationsRegistry` registry. :param arg: an optional, context specific, argument For example a curve name. :raises InvalidJWKOperation: if the operation is unknown or not permitted with this key. :raises InvalidJWKUsage: if the use constraints do not permit the operation. """ validops = self._params.get('key_ops', list(JWKOperationsRegistry.keys())) if validops is not list: validops = [validops] if operation is None: if self._params['kty'] == 'oct': return self._key['k'] raise InvalidJWKOperation(operation, validops) elif operation == 'sign': self._check_constraints('sig', operation) return self._get_private_key(arg) elif operation == 'verify': self._check_constraints('sig', operation) return self._get_public_key(arg) elif operation == 'encrypt' or operation == 'wrapKey': self._check_constraints('enc', operation) return self._get_public_key(arg) elif operation == 'decrypt' or operation == 'unwrapKey': self._check_constraints('enc', operation) return self._get_private_key(arg) else: raise NotImplementedError
[ "def", "get_op_key", "(", "self", ",", "operation", "=", "None", ",", "arg", "=", "None", ")", ":", "validops", "=", "self", ".", "_params", ".", "get", "(", "'key_ops'", ",", "list", "(", "JWKOperationsRegistry", ".", "keys", "(", ")", ")", ")", "if...
Get the key object associated to the requested opration. For example the public RSA key for the 'verify' operation or the private EC key for the 'decrypt' operation. :param operation: The requested operation. The valid set of operations is availble in the :data:`JWKOperationsRegistry` registry. :param arg: an optional, context specific, argument For example a curve name. :raises InvalidJWKOperation: if the operation is unknown or not permitted with this key. :raises InvalidJWKUsage: if the use constraints do not permit the operation.
[ "Get", "the", "key", "object", "associated", "to", "the", "requested", "opration", ".", "For", "example", "the", "public", "RSA", "key", "for", "the", "verify", "operation", "or", "the", "private", "EC", "key", "for", "the", "decrypt", "operation", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwk.py#L708-L745
train
202,883
latchset/jwcrypto
jwcrypto/jwk.py
JWK.thumbprint
def thumbprint(self, hashalg=hashes.SHA256()): """Returns the key thumbprint as specified by RFC 7638. :param hashalg: A hash function (defaults to SHA256) """ t = {'kty': self._params['kty']} for name, val in iteritems(JWKValuesRegistry[t['kty']]): if val.required: t[name] = self._key[name] digest = hashes.Hash(hashalg, backend=default_backend()) digest.update(bytes(json_encode(t).encode('utf8'))) return base64url_encode(digest.finalize())
python
def thumbprint(self, hashalg=hashes.SHA256()): """Returns the key thumbprint as specified by RFC 7638. :param hashalg: A hash function (defaults to SHA256) """ t = {'kty': self._params['kty']} for name, val in iteritems(JWKValuesRegistry[t['kty']]): if val.required: t[name] = self._key[name] digest = hashes.Hash(hashalg, backend=default_backend()) digest.update(bytes(json_encode(t).encode('utf8'))) return base64url_encode(digest.finalize())
[ "def", "thumbprint", "(", "self", ",", "hashalg", "=", "hashes", ".", "SHA256", "(", ")", ")", ":", "t", "=", "{", "'kty'", ":", "self", ".", "_params", "[", "'kty'", "]", "}", "for", "name", ",", "val", "in", "iteritems", "(", "JWKValuesRegistry", ...
Returns the key thumbprint as specified by RFC 7638. :param hashalg: A hash function (defaults to SHA256)
[ "Returns", "the", "key", "thumbprint", "as", "specified", "by", "RFC", "7638", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwk.py#L848-L860
train
202,884
latchset/jwcrypto
jwcrypto/jwk.py
_JWKkeys.add
def add(self, elem): """Adds a JWK object to the set :param elem: the JWK object to add. :raises TypeError: if the object is not a JWK. """ if not isinstance(elem, JWK): raise TypeError('Only JWK objects are valid elements') set.add(self, elem)
python
def add(self, elem): """Adds a JWK object to the set :param elem: the JWK object to add. :raises TypeError: if the object is not a JWK. """ if not isinstance(elem, JWK): raise TypeError('Only JWK objects are valid elements') set.add(self, elem)
[ "def", "add", "(", "self", ",", "elem", ")", ":", "if", "not", "isinstance", "(", "elem", ",", "JWK", ")", ":", "raise", "TypeError", "(", "'Only JWK objects are valid elements'", ")", "set", ".", "add", "(", "self", ",", "elem", ")" ]
Adds a JWK object to the set :param elem: the JWK object to add. :raises TypeError: if the object is not a JWK.
[ "Adds", "a", "JWK", "object", "to", "the", "set" ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwk.py#L865-L874
train
202,885
latchset/jwcrypto
jwcrypto/jwk.py
JWKSet.export
def export(self, private_keys=True): """Exports a RFC 7517 keyset using the standard JSON format :param private_key(bool): Whether to export private keys. Defaults to True. """ exp_dict = dict() for k, v in iteritems(self): if k == 'keys': keys = list() for jwk in v: keys.append(json_decode(jwk.export(private_keys))) v = keys exp_dict[k] = v return json_encode(exp_dict)
python
def export(self, private_keys=True): """Exports a RFC 7517 keyset using the standard JSON format :param private_key(bool): Whether to export private keys. Defaults to True. """ exp_dict = dict() for k, v in iteritems(self): if k == 'keys': keys = list() for jwk in v: keys.append(json_decode(jwk.export(private_keys))) v = keys exp_dict[k] = v return json_encode(exp_dict)
[ "def", "export", "(", "self", ",", "private_keys", "=", "True", ")", ":", "exp_dict", "=", "dict", "(", ")", "for", "k", ",", "v", "in", "iteritems", "(", "self", ")", ":", "if", "k", "==", "'keys'", ":", "keys", "=", "list", "(", ")", "for", "...
Exports a RFC 7517 keyset using the standard JSON format :param private_key(bool): Whether to export private keys. Defaults to True.
[ "Exports", "a", "RFC", "7517", "keyset", "using", "the", "standard", "JSON", "format" ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwk.py#L908-L922
train
202,886
latchset/jwcrypto
jwcrypto/jwk.py
JWKSet.import_keyset
def import_keyset(self, keyset): """Imports a RFC 7517 keyset using the standard JSON format. :param keyset: The RFC 7517 representation of a JOSE Keyset. """ try: jwkset = json_decode(keyset) except Exception: # pylint: disable=broad-except raise InvalidJWKValue() if 'keys' not in jwkset: raise InvalidJWKValue() for k, v in iteritems(jwkset): if k == 'keys': for jwk in v: self['keys'].add(JWK(**jwk)) else: self[k] = v
python
def import_keyset(self, keyset): """Imports a RFC 7517 keyset using the standard JSON format. :param keyset: The RFC 7517 representation of a JOSE Keyset. """ try: jwkset = json_decode(keyset) except Exception: # pylint: disable=broad-except raise InvalidJWKValue() if 'keys' not in jwkset: raise InvalidJWKValue() for k, v in iteritems(jwkset): if k == 'keys': for jwk in v: self['keys'].add(JWK(**jwk)) else: self[k] = v
[ "def", "import_keyset", "(", "self", ",", "keyset", ")", ":", "try", ":", "jwkset", "=", "json_decode", "(", "keyset", ")", "except", "Exception", ":", "# pylint: disable=broad-except", "raise", "InvalidJWKValue", "(", ")", "if", "'keys'", "not", "in", "jwkset...
Imports a RFC 7517 keyset using the standard JSON format. :param keyset: The RFC 7517 representation of a JOSE Keyset.
[ "Imports", "a", "RFC", "7517", "keyset", "using", "the", "standard", "JSON", "format", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwk.py#L924-L942
train
202,887
latchset/jwcrypto
jwcrypto/jwe.py
JWE.add_recipient
def add_recipient(self, key, header=None): """Encrypt the plaintext with the given key. :param key: A JWK key or password of appropriate type for the 'alg' provided in the JOSE Headers. :param header: A JSON string representing the per-recipient header. :raises ValueError: if the plaintext is missing or not of type bytes. :raises ValueError: if the compression type is unknown. :raises InvalidJWAAlgorithm: if the 'alg' provided in the JOSE headers is missing or unknown, or otherwise not implemented. """ if self.plaintext is None: raise ValueError('Missing plaintext') if not isinstance(self.plaintext, bytes): raise ValueError("Plaintext must be 'bytes'") if isinstance(header, dict): header = json_encode(header) jh = self._get_jose_header(header) alg, enc = self._get_alg_enc_from_headers(jh) rec = dict() if header: rec['header'] = header wrapped = alg.wrap(key, enc.wrap_key_size, self.cek, jh) self.cek = wrapped['cek'] if 'ek' in wrapped: rec['encrypted_key'] = wrapped['ek'] if 'header' in wrapped: h = json_decode(rec.get('header', '{}')) nh = self._merge_headers(h, wrapped['header']) rec['header'] = json_encode(nh) if 'ciphertext' not in self.objects: self._encrypt(alg, enc, jh) if 'recipients' in self.objects: self.objects['recipients'].append(rec) elif 'encrypted_key' in self.objects or 'header' in self.objects: self.objects['recipients'] = list() n = dict() if 'encrypted_key' in self.objects: n['encrypted_key'] = self.objects.pop('encrypted_key') if 'header' in self.objects: n['header'] = self.objects.pop('header') self.objects['recipients'].append(n) self.objects['recipients'].append(rec) else: self.objects.update(rec)
python
def add_recipient(self, key, header=None): """Encrypt the plaintext with the given key. :param key: A JWK key or password of appropriate type for the 'alg' provided in the JOSE Headers. :param header: A JSON string representing the per-recipient header. :raises ValueError: if the plaintext is missing or not of type bytes. :raises ValueError: if the compression type is unknown. :raises InvalidJWAAlgorithm: if the 'alg' provided in the JOSE headers is missing or unknown, or otherwise not implemented. """ if self.plaintext is None: raise ValueError('Missing plaintext') if not isinstance(self.plaintext, bytes): raise ValueError("Plaintext must be 'bytes'") if isinstance(header, dict): header = json_encode(header) jh = self._get_jose_header(header) alg, enc = self._get_alg_enc_from_headers(jh) rec = dict() if header: rec['header'] = header wrapped = alg.wrap(key, enc.wrap_key_size, self.cek, jh) self.cek = wrapped['cek'] if 'ek' in wrapped: rec['encrypted_key'] = wrapped['ek'] if 'header' in wrapped: h = json_decode(rec.get('header', '{}')) nh = self._merge_headers(h, wrapped['header']) rec['header'] = json_encode(nh) if 'ciphertext' not in self.objects: self._encrypt(alg, enc, jh) if 'recipients' in self.objects: self.objects['recipients'].append(rec) elif 'encrypted_key' in self.objects or 'header' in self.objects: self.objects['recipients'] = list() n = dict() if 'encrypted_key' in self.objects: n['encrypted_key'] = self.objects.pop('encrypted_key') if 'header' in self.objects: n['header'] = self.objects.pop('header') self.objects['recipients'].append(n) self.objects['recipients'].append(rec) else: self.objects.update(rec)
[ "def", "add_recipient", "(", "self", ",", "key", ",", "header", "=", "None", ")", ":", "if", "self", ".", "plaintext", "is", "None", ":", "raise", "ValueError", "(", "'Missing plaintext'", ")", "if", "not", "isinstance", "(", "self", ".", "plaintext", ",...
Encrypt the plaintext with the given key. :param key: A JWK key or password of appropriate type for the 'alg' provided in the JOSE Headers. :param header: A JSON string representing the per-recipient header. :raises ValueError: if the plaintext is missing or not of type bytes. :raises ValueError: if the compression type is unknown. :raises InvalidJWAAlgorithm: if the 'alg' provided in the JOSE headers is missing or unknown, or otherwise not implemented.
[ "Encrypt", "the", "plaintext", "with", "the", "given", "key", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwe.py#L209-L262
train
202,888
latchset/jwcrypto
jwcrypto/jwe.py
JWE.serialize
def serialize(self, compact=False): """Serializes the object into a JWE token. :param compact(boolean): if True generates the compact representation, otherwise generates a standard JSON format. :raises InvalidJWEOperation: if the object cannot serialized with the compact representation and `compact` is True. :raises InvalidJWEOperation: if no recipients have been added to the object. """ if 'ciphertext' not in self.objects: raise InvalidJWEOperation("No available ciphertext") if compact: for invalid in 'aad', 'unprotected': if invalid in self.objects: raise InvalidJWEOperation( "Can't use compact encoding when the '%s' parameter" "is set" % invalid) if 'protected' not in self.objects: raise InvalidJWEOperation( "Can't use compat encoding without protected headers") else: ph = json_decode(self.objects['protected']) for required in 'alg', 'enc': if required not in ph: raise InvalidJWEOperation( "Can't use compat encoding, '%s' must be in the " "protected header" % required) if 'recipients' in self.objects: if len(self.objects['recipients']) != 1: raise InvalidJWEOperation("Invalid number of recipients") rec = self.objects['recipients'][0] else: rec = self.objects if 'header' in rec: # The AESGCMKW algorithm generates data (iv, tag) we put in the # per-recipient unpotected header by default. Move it to the # protected header and re-encrypt the payload, as the protected # header is used as additional authenticated data. h = json_decode(rec['header']) ph = json_decode(self.objects['protected']) nph = self._merge_headers(h, ph) self.objects['protected'] = json_encode(nph) jh = self._get_jose_header() alg, enc = self._get_alg_enc_from_headers(jh) self._encrypt(alg, enc, jh) del rec['header'] return '.'.join([base64url_encode(self.objects['protected']), base64url_encode(rec.get('encrypted_key', '')), base64url_encode(self.objects['iv']), base64url_encode(self.objects['ciphertext']), base64url_encode(self.objects['tag'])]) else: obj = self.objects enc = {'ciphertext': base64url_encode(obj['ciphertext']), 'iv': base64url_encode(obj['iv']), 'tag': base64url_encode(self.objects['tag'])} if 'protected' in obj: enc['protected'] = base64url_encode(obj['protected']) if 'unprotected' in obj: enc['unprotected'] = json_decode(obj['unprotected']) if 'aad' in obj: enc['aad'] = base64url_encode(obj['aad']) if 'recipients' in obj: enc['recipients'] = list() for rec in obj['recipients']: e = dict() if 'encrypted_key' in rec: e['encrypted_key'] = \ base64url_encode(rec['encrypted_key']) if 'header' in rec: e['header'] = json_decode(rec['header']) enc['recipients'].append(e) else: if 'encrypted_key' in obj: enc['encrypted_key'] = \ base64url_encode(obj['encrypted_key']) if 'header' in obj: enc['header'] = json_decode(obj['header']) return json_encode(enc)
python
def serialize(self, compact=False): """Serializes the object into a JWE token. :param compact(boolean): if True generates the compact representation, otherwise generates a standard JSON format. :raises InvalidJWEOperation: if the object cannot serialized with the compact representation and `compact` is True. :raises InvalidJWEOperation: if no recipients have been added to the object. """ if 'ciphertext' not in self.objects: raise InvalidJWEOperation("No available ciphertext") if compact: for invalid in 'aad', 'unprotected': if invalid in self.objects: raise InvalidJWEOperation( "Can't use compact encoding when the '%s' parameter" "is set" % invalid) if 'protected' not in self.objects: raise InvalidJWEOperation( "Can't use compat encoding without protected headers") else: ph = json_decode(self.objects['protected']) for required in 'alg', 'enc': if required not in ph: raise InvalidJWEOperation( "Can't use compat encoding, '%s' must be in the " "protected header" % required) if 'recipients' in self.objects: if len(self.objects['recipients']) != 1: raise InvalidJWEOperation("Invalid number of recipients") rec = self.objects['recipients'][0] else: rec = self.objects if 'header' in rec: # The AESGCMKW algorithm generates data (iv, tag) we put in the # per-recipient unpotected header by default. Move it to the # protected header and re-encrypt the payload, as the protected # header is used as additional authenticated data. h = json_decode(rec['header']) ph = json_decode(self.objects['protected']) nph = self._merge_headers(h, ph) self.objects['protected'] = json_encode(nph) jh = self._get_jose_header() alg, enc = self._get_alg_enc_from_headers(jh) self._encrypt(alg, enc, jh) del rec['header'] return '.'.join([base64url_encode(self.objects['protected']), base64url_encode(rec.get('encrypted_key', '')), base64url_encode(self.objects['iv']), base64url_encode(self.objects['ciphertext']), base64url_encode(self.objects['tag'])]) else: obj = self.objects enc = {'ciphertext': base64url_encode(obj['ciphertext']), 'iv': base64url_encode(obj['iv']), 'tag': base64url_encode(self.objects['tag'])} if 'protected' in obj: enc['protected'] = base64url_encode(obj['protected']) if 'unprotected' in obj: enc['unprotected'] = json_decode(obj['unprotected']) if 'aad' in obj: enc['aad'] = base64url_encode(obj['aad']) if 'recipients' in obj: enc['recipients'] = list() for rec in obj['recipients']: e = dict() if 'encrypted_key' in rec: e['encrypted_key'] = \ base64url_encode(rec['encrypted_key']) if 'header' in rec: e['header'] = json_decode(rec['header']) enc['recipients'].append(e) else: if 'encrypted_key' in obj: enc['encrypted_key'] = \ base64url_encode(obj['encrypted_key']) if 'header' in obj: enc['header'] = json_decode(obj['header']) return json_encode(enc)
[ "def", "serialize", "(", "self", ",", "compact", "=", "False", ")", ":", "if", "'ciphertext'", "not", "in", "self", ".", "objects", ":", "raise", "InvalidJWEOperation", "(", "\"No available ciphertext\"", ")", "if", "compact", ":", "for", "invalid", "in", "'...
Serializes the object into a JWE token. :param compact(boolean): if True generates the compact representation, otherwise generates a standard JSON format. :raises InvalidJWEOperation: if the object cannot serialized with the compact representation and `compact` is True. :raises InvalidJWEOperation: if no recipients have been added to the object.
[ "Serializes", "the", "object", "into", "a", "JWE", "token", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwe.py#L264-L347
train
202,889
latchset/jwcrypto
jwcrypto/jwe.py
JWE.decrypt
def decrypt(self, key): """Decrypt a JWE token. :param key: The (:class:`jwcrypto.jwk.JWK`) decryption key. :param key: A (:class:`jwcrypto.jwk.JWK`) decryption key or a password string (optional). :raises InvalidJWEOperation: if the key is not a JWK object. :raises InvalidJWEData: if the ciphertext can't be decrypted or the object is otherwise malformed. """ if 'ciphertext' not in self.objects: raise InvalidJWEOperation("No available ciphertext") self.decryptlog = list() if 'recipients' in self.objects: for rec in self.objects['recipients']: try: self._decrypt(key, rec) except Exception as e: # pylint: disable=broad-except self.decryptlog.append('Failed: [%s]' % repr(e)) else: try: self._decrypt(key, self.objects) except Exception as e: # pylint: disable=broad-except self.decryptlog.append('Failed: [%s]' % repr(e)) if not self.plaintext: raise InvalidJWEData('No recipient matched the provided ' 'key' + repr(self.decryptlog))
python
def decrypt(self, key): """Decrypt a JWE token. :param key: The (:class:`jwcrypto.jwk.JWK`) decryption key. :param key: A (:class:`jwcrypto.jwk.JWK`) decryption key or a password string (optional). :raises InvalidJWEOperation: if the key is not a JWK object. :raises InvalidJWEData: if the ciphertext can't be decrypted or the object is otherwise malformed. """ if 'ciphertext' not in self.objects: raise InvalidJWEOperation("No available ciphertext") self.decryptlog = list() if 'recipients' in self.objects: for rec in self.objects['recipients']: try: self._decrypt(key, rec) except Exception as e: # pylint: disable=broad-except self.decryptlog.append('Failed: [%s]' % repr(e)) else: try: self._decrypt(key, self.objects) except Exception as e: # pylint: disable=broad-except self.decryptlog.append('Failed: [%s]' % repr(e)) if not self.plaintext: raise InvalidJWEData('No recipient matched the provided ' 'key' + repr(self.decryptlog))
[ "def", "decrypt", "(", "self", ",", "key", ")", ":", "if", "'ciphertext'", "not", "in", "self", ".", "objects", ":", "raise", "InvalidJWEOperation", "(", "\"No available ciphertext\"", ")", "self", ".", "decryptlog", "=", "list", "(", ")", "if", "'recipients...
Decrypt a JWE token. :param key: The (:class:`jwcrypto.jwk.JWK`) decryption key. :param key: A (:class:`jwcrypto.jwk.JWK`) decryption key or a password string (optional). :raises InvalidJWEOperation: if the key is not a JWK object. :raises InvalidJWEData: if the ciphertext can't be decrypted or the object is otherwise malformed.
[ "Decrypt", "a", "JWE", "token", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwe.py#L396-L426
train
202,890
latchset/jwcrypto
jwcrypto/jwe.py
JWE.deserialize
def deserialize(self, raw_jwe, key=None): """Deserialize a JWE token. NOTE: Destroys any current status and tries to import the raw JWE provided. :param raw_jwe: a 'raw' JWE token (JSON Encoded or Compact notation) string. :param key: A (:class:`jwcrypto.jwk.JWK`) decryption key or a password string (optional). If a key is provided a decryption step will be attempted after the object is successfully deserialized. :raises InvalidJWEData: if the raw object is an invaid JWE token. :raises InvalidJWEOperation: if the decryption fails. """ self.objects = dict() self.plaintext = None self.cek = None o = dict() try: try: djwe = json_decode(raw_jwe) o['iv'] = base64url_decode(djwe['iv']) o['ciphertext'] = base64url_decode(djwe['ciphertext']) o['tag'] = base64url_decode(djwe['tag']) if 'protected' in djwe: p = base64url_decode(djwe['protected']) o['protected'] = p.decode('utf-8') if 'unprotected' in djwe: o['unprotected'] = json_encode(djwe['unprotected']) if 'aad' in djwe: o['aad'] = base64url_decode(djwe['aad']) if 'recipients' in djwe: o['recipients'] = list() for rec in djwe['recipients']: e = dict() if 'encrypted_key' in rec: e['encrypted_key'] = \ base64url_decode(rec['encrypted_key']) if 'header' in rec: e['header'] = json_encode(rec['header']) o['recipients'].append(e) else: if 'encrypted_key' in djwe: o['encrypted_key'] = \ base64url_decode(djwe['encrypted_key']) if 'header' in djwe: o['header'] = json_encode(djwe['header']) except ValueError: c = raw_jwe.split('.') if len(c) != 5: raise InvalidJWEData() p = base64url_decode(c[0]) o['protected'] = p.decode('utf-8') ekey = base64url_decode(c[1]) if ekey != b'': o['encrypted_key'] = base64url_decode(c[1]) o['iv'] = base64url_decode(c[2]) o['ciphertext'] = base64url_decode(c[3]) o['tag'] = base64url_decode(c[4]) self.objects = o except Exception as e: # pylint: disable=broad-except raise InvalidJWEData('Invalid format', repr(e)) if key: self.decrypt(key)
python
def deserialize(self, raw_jwe, key=None): """Deserialize a JWE token. NOTE: Destroys any current status and tries to import the raw JWE provided. :param raw_jwe: a 'raw' JWE token (JSON Encoded or Compact notation) string. :param key: A (:class:`jwcrypto.jwk.JWK`) decryption key or a password string (optional). If a key is provided a decryption step will be attempted after the object is successfully deserialized. :raises InvalidJWEData: if the raw object is an invaid JWE token. :raises InvalidJWEOperation: if the decryption fails. """ self.objects = dict() self.plaintext = None self.cek = None o = dict() try: try: djwe = json_decode(raw_jwe) o['iv'] = base64url_decode(djwe['iv']) o['ciphertext'] = base64url_decode(djwe['ciphertext']) o['tag'] = base64url_decode(djwe['tag']) if 'protected' in djwe: p = base64url_decode(djwe['protected']) o['protected'] = p.decode('utf-8') if 'unprotected' in djwe: o['unprotected'] = json_encode(djwe['unprotected']) if 'aad' in djwe: o['aad'] = base64url_decode(djwe['aad']) if 'recipients' in djwe: o['recipients'] = list() for rec in djwe['recipients']: e = dict() if 'encrypted_key' in rec: e['encrypted_key'] = \ base64url_decode(rec['encrypted_key']) if 'header' in rec: e['header'] = json_encode(rec['header']) o['recipients'].append(e) else: if 'encrypted_key' in djwe: o['encrypted_key'] = \ base64url_decode(djwe['encrypted_key']) if 'header' in djwe: o['header'] = json_encode(djwe['header']) except ValueError: c = raw_jwe.split('.') if len(c) != 5: raise InvalidJWEData() p = base64url_decode(c[0]) o['protected'] = p.decode('utf-8') ekey = base64url_decode(c[1]) if ekey != b'': o['encrypted_key'] = base64url_decode(c[1]) o['iv'] = base64url_decode(c[2]) o['ciphertext'] = base64url_decode(c[3]) o['tag'] = base64url_decode(c[4]) self.objects = o except Exception as e: # pylint: disable=broad-except raise InvalidJWEData('Invalid format', repr(e)) if key: self.decrypt(key)
[ "def", "deserialize", "(", "self", ",", "raw_jwe", ",", "key", "=", "None", ")", ":", "self", ".", "objects", "=", "dict", "(", ")", "self", ".", "plaintext", "=", "None", "self", ".", "cek", "=", "None", "o", "=", "dict", "(", ")", "try", ":", ...
Deserialize a JWE token. NOTE: Destroys any current status and tries to import the raw JWE provided. :param raw_jwe: a 'raw' JWE token (JSON Encoded or Compact notation) string. :param key: A (:class:`jwcrypto.jwk.JWK`) decryption key or a password string (optional). If a key is provided a decryption step will be attempted after the object is successfully deserialized. :raises InvalidJWEData: if the raw object is an invaid JWE token. :raises InvalidJWEOperation: if the decryption fails.
[ "Deserialize", "a", "JWE", "token", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwe.py#L428-L499
train
202,891
latchset/jwcrypto
jwcrypto/jws.py
JWSCore.sign
def sign(self): """Generates a signature""" payload = self._payload() sigin = b'.'.join([self.protected.encode('utf-8'), payload]) signature = self.engine.sign(self.key, sigin) return {'protected': self.protected, 'payload': payload, 'signature': base64url_encode(signature)}
python
def sign(self): """Generates a signature""" payload = self._payload() sigin = b'.'.join([self.protected.encode('utf-8'), payload]) signature = self.engine.sign(self.key, sigin) return {'protected': self.protected, 'payload': payload, 'signature': base64url_encode(signature)}
[ "def", "sign", "(", "self", ")", ":", "payload", "=", "self", ".", "_payload", "(", ")", "sigin", "=", "b'.'", ".", "join", "(", "[", "self", ".", "protected", ".", "encode", "(", "'utf-8'", ")", ",", "payload", "]", ")", "signature", "=", "self", ...
Generates a signature
[ "Generates", "a", "signature" ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jws.py#L147-L154
train
202,892
latchset/jwcrypto
jwcrypto/jws.py
JWSCore.verify
def verify(self, signature): """Verifies a signature :raises InvalidJWSSignature: if the verification fails. """ try: payload = self._payload() sigin = b'.'.join([self.protected.encode('utf-8'), payload]) self.engine.verify(self.key, sigin, signature) except Exception as e: # pylint: disable=broad-except raise InvalidJWSSignature('Verification failed', repr(e)) return True
python
def verify(self, signature): """Verifies a signature :raises InvalidJWSSignature: if the verification fails. """ try: payload = self._payload() sigin = b'.'.join([self.protected.encode('utf-8'), payload]) self.engine.verify(self.key, sigin, signature) except Exception as e: # pylint: disable=broad-except raise InvalidJWSSignature('Verification failed', repr(e)) return True
[ "def", "verify", "(", "self", ",", "signature", ")", ":", "try", ":", "payload", "=", "self", ".", "_payload", "(", ")", "sigin", "=", "b'.'", ".", "join", "(", "[", "self", ".", "protected", ".", "encode", "(", "'utf-8'", ")", ",", "payload", "]",...
Verifies a signature :raises InvalidJWSSignature: if the verification fails.
[ "Verifies", "a", "signature" ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jws.py#L156-L167
train
202,893
latchset/jwcrypto
jwcrypto/jws.py
JWS.verify
def verify(self, key, alg=None): """Verifies a JWS token. :param key: The (:class:`jwcrypto.jwk.JWK`) verification key. :param alg: The signing algorithm (optional). usually the algorithm is known as it is provided with the JOSE Headers of the token. :raises InvalidJWSSignature: if the verification fails. """ self.verifylog = list() self.objects['valid'] = False obj = self.objects if 'signature' in obj: try: self._verify(alg, key, obj['payload'], obj['signature'], obj.get('protected', None), obj.get('header', None)) obj['valid'] = True except Exception as e: # pylint: disable=broad-except self.verifylog.append('Failed: [%s]' % repr(e)) elif 'signatures' in obj: for o in obj['signatures']: try: self._verify(alg, key, obj['payload'], o['signature'], o.get('protected', None), o.get('header', None)) # Ok if at least one verifies obj['valid'] = True except Exception as e: # pylint: disable=broad-except self.verifylog.append('Failed: [%s]' % repr(e)) else: raise InvalidJWSSignature('No signatures availble') if not self.is_valid: raise InvalidJWSSignature('Verification failed for all ' 'signatures' + repr(self.verifylog))
python
def verify(self, key, alg=None): """Verifies a JWS token. :param key: The (:class:`jwcrypto.jwk.JWK`) verification key. :param alg: The signing algorithm (optional). usually the algorithm is known as it is provided with the JOSE Headers of the token. :raises InvalidJWSSignature: if the verification fails. """ self.verifylog = list() self.objects['valid'] = False obj = self.objects if 'signature' in obj: try: self._verify(alg, key, obj['payload'], obj['signature'], obj.get('protected', None), obj.get('header', None)) obj['valid'] = True except Exception as e: # pylint: disable=broad-except self.verifylog.append('Failed: [%s]' % repr(e)) elif 'signatures' in obj: for o in obj['signatures']: try: self._verify(alg, key, obj['payload'], o['signature'], o.get('protected', None), o.get('header', None)) # Ok if at least one verifies obj['valid'] = True except Exception as e: # pylint: disable=broad-except self.verifylog.append('Failed: [%s]' % repr(e)) else: raise InvalidJWSSignature('No signatures availble') if not self.is_valid: raise InvalidJWSSignature('Verification failed for all ' 'signatures' + repr(self.verifylog))
[ "def", "verify", "(", "self", ",", "key", ",", "alg", "=", "None", ")", ":", "self", ".", "verifylog", "=", "list", "(", ")", "self", ".", "objects", "[", "'valid'", "]", "=", "False", "obj", "=", "self", ".", "objects", "if", "'signature'", "in", ...
Verifies a JWS token. :param key: The (:class:`jwcrypto.jwk.JWK`) verification key. :param alg: The signing algorithm (optional). usually the algorithm is known as it is provided with the JOSE Headers of the token. :raises InvalidJWSSignature: if the verification fails.
[ "Verifies", "a", "JWS", "token", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jws.py#L292-L333
train
202,894
latchset/jwcrypto
jwcrypto/jws.py
JWS.deserialize
def deserialize(self, raw_jws, key=None, alg=None): """Deserialize a JWS token. NOTE: Destroys any current status and tries to import the raw JWS provided. :param raw_jws: a 'raw' JWS token (JSON Encoded or Compact notation) string. :param key: A (:class:`jwcrypto.jwk.JWK`) verification key (optional). If a key is provided a verification step will be attempted after the object is successfully deserialized. :param alg: The signing algorithm (optional). usually the algorithm is known as it is provided with the JOSE Headers of the token. :raises InvalidJWSObject: if the raw object is an invaid JWS token. :raises InvalidJWSSignature: if the verification fails. """ self.objects = dict() o = dict() try: try: djws = json_decode(raw_jws) if 'signatures' in djws: o['signatures'] = list() for s in djws['signatures']: os = self._deserialize_signature(s) o['signatures'].append(os) self._deserialize_b64(o, os.get('protected')) else: o = self._deserialize_signature(djws) self._deserialize_b64(o, o.get('protected')) if 'payload' in djws: if o.get('b64', True): o['payload'] = base64url_decode(str(djws['payload'])) else: o['payload'] = djws['payload'] except ValueError: c = raw_jws.split('.') if len(c) != 3: raise InvalidJWSObject('Unrecognized representation') p = base64url_decode(str(c[0])) if len(p) > 0: o['protected'] = p.decode('utf-8') self._deserialize_b64(o, o['protected']) o['payload'] = base64url_decode(str(c[1])) o['signature'] = base64url_decode(str(c[2])) self.objects = o except Exception as e: # pylint: disable=broad-except raise InvalidJWSObject('Invalid format', repr(e)) if key: self.verify(key, alg)
python
def deserialize(self, raw_jws, key=None, alg=None): """Deserialize a JWS token. NOTE: Destroys any current status and tries to import the raw JWS provided. :param raw_jws: a 'raw' JWS token (JSON Encoded or Compact notation) string. :param key: A (:class:`jwcrypto.jwk.JWK`) verification key (optional). If a key is provided a verification step will be attempted after the object is successfully deserialized. :param alg: The signing algorithm (optional). usually the algorithm is known as it is provided with the JOSE Headers of the token. :raises InvalidJWSObject: if the raw object is an invaid JWS token. :raises InvalidJWSSignature: if the verification fails. """ self.objects = dict() o = dict() try: try: djws = json_decode(raw_jws) if 'signatures' in djws: o['signatures'] = list() for s in djws['signatures']: os = self._deserialize_signature(s) o['signatures'].append(os) self._deserialize_b64(o, os.get('protected')) else: o = self._deserialize_signature(djws) self._deserialize_b64(o, o.get('protected')) if 'payload' in djws: if o.get('b64', True): o['payload'] = base64url_decode(str(djws['payload'])) else: o['payload'] = djws['payload'] except ValueError: c = raw_jws.split('.') if len(c) != 3: raise InvalidJWSObject('Unrecognized representation') p = base64url_decode(str(c[0])) if len(p) > 0: o['protected'] = p.decode('utf-8') self._deserialize_b64(o, o['protected']) o['payload'] = base64url_decode(str(c[1])) o['signature'] = base64url_decode(str(c[2])) self.objects = o except Exception as e: # pylint: disable=broad-except raise InvalidJWSObject('Invalid format', repr(e)) if key: self.verify(key, alg)
[ "def", "deserialize", "(", "self", ",", "raw_jws", ",", "key", "=", "None", ",", "alg", "=", "None", ")", ":", "self", ".", "objects", "=", "dict", "(", ")", "o", "=", "dict", "(", ")", "try", ":", "try", ":", "djws", "=", "json_decode", "(", "...
Deserialize a JWS token. NOTE: Destroys any current status and tries to import the raw JWS provided. :param raw_jws: a 'raw' JWS token (JSON Encoded or Compact notation) string. :param key: A (:class:`jwcrypto.jwk.JWK`) verification key (optional). If a key is provided a verification step will be attempted after the object is successfully deserialized. :param alg: The signing algorithm (optional). usually the algorithm is known as it is provided with the JOSE Headers of the token. :raises InvalidJWSObject: if the raw object is an invaid JWS token. :raises InvalidJWSSignature: if the verification fails.
[ "Deserialize", "a", "JWS", "token", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jws.py#L362-L417
train
202,895
latchset/jwcrypto
jwcrypto/jws.py
JWS.add_signature
def add_signature(self, key, alg=None, protected=None, header=None): """Adds a new signature to the object. :param key: A (:class:`jwcrypto.jwk.JWK`) key of appropriate for the "alg" provided. :param alg: An optional algorithm name. If already provided as an element of the protected or unprotected header it can be safely omitted. :param potected: The Protected Header (optional) :param header: The Unprotected Header (optional) :raises InvalidJWSObject: if no payload has been set on the object, or invalid headers are provided. :raises ValueError: if the key is not a :class:`JWK` object. :raises ValueError: if the algorithm is missing or is not provided by one of the headers. :raises InvalidJWAAlgorithm: if the algorithm is not valid, is unknown or otherwise not yet implemented. """ if not self.objects.get('payload', None): raise InvalidJWSObject('Missing Payload') b64 = True p = dict() if protected: if isinstance(protected, dict): p = protected protected = json_encode(p) else: p = json_decode(protected) # If b64 is present we must enforce criticality if 'b64' in list(p.keys()): crit = p.get('crit', []) if 'b64' not in crit: raise InvalidJWSObject('b64 header must always be critical') b64 = p['b64'] if 'b64' in self.objects: if b64 != self.objects['b64']: raise InvalidJWSObject('Mixed b64 headers on signatures') h = None if header: if isinstance(header, dict): h = header header = json_encode(header) else: h = json_decode(header) p = self._merge_check_headers(p, h) if 'alg' in p: if alg is None: alg = p['alg'] elif alg != p['alg']: raise ValueError('"alg" value mismatch, specified "alg" ' 'does not match JOSE header value') if alg is None: raise ValueError('"alg" not specified') c = JWSCore(alg, key, protected, self.objects['payload']) sig = c.sign() o = dict() o['signature'] = base64url_decode(sig['signature']) if protected: o['protected'] = protected if header: o['header'] = h o['valid'] = True if 'signatures' in self.objects: self.objects['signatures'].append(o) elif 'signature' in self.objects: self.objects['signatures'] = list() n = dict() n['signature'] = self.objects.pop('signature') if 'protected' in self.objects: n['protected'] = self.objects.pop('protected') if 'header' in self.objects: n['header'] = self.objects.pop('header') if 'valid' in self.objects: n['valid'] = self.objects.pop('valid') self.objects['signatures'].append(n) self.objects['signatures'].append(o) else: self.objects.update(o) self.objects['b64'] = b64
python
def add_signature(self, key, alg=None, protected=None, header=None): """Adds a new signature to the object. :param key: A (:class:`jwcrypto.jwk.JWK`) key of appropriate for the "alg" provided. :param alg: An optional algorithm name. If already provided as an element of the protected or unprotected header it can be safely omitted. :param potected: The Protected Header (optional) :param header: The Unprotected Header (optional) :raises InvalidJWSObject: if no payload has been set on the object, or invalid headers are provided. :raises ValueError: if the key is not a :class:`JWK` object. :raises ValueError: if the algorithm is missing or is not provided by one of the headers. :raises InvalidJWAAlgorithm: if the algorithm is not valid, is unknown or otherwise not yet implemented. """ if not self.objects.get('payload', None): raise InvalidJWSObject('Missing Payload') b64 = True p = dict() if protected: if isinstance(protected, dict): p = protected protected = json_encode(p) else: p = json_decode(protected) # If b64 is present we must enforce criticality if 'b64' in list(p.keys()): crit = p.get('crit', []) if 'b64' not in crit: raise InvalidJWSObject('b64 header must always be critical') b64 = p['b64'] if 'b64' in self.objects: if b64 != self.objects['b64']: raise InvalidJWSObject('Mixed b64 headers on signatures') h = None if header: if isinstance(header, dict): h = header header = json_encode(header) else: h = json_decode(header) p = self._merge_check_headers(p, h) if 'alg' in p: if alg is None: alg = p['alg'] elif alg != p['alg']: raise ValueError('"alg" value mismatch, specified "alg" ' 'does not match JOSE header value') if alg is None: raise ValueError('"alg" not specified') c = JWSCore(alg, key, protected, self.objects['payload']) sig = c.sign() o = dict() o['signature'] = base64url_decode(sig['signature']) if protected: o['protected'] = protected if header: o['header'] = h o['valid'] = True if 'signatures' in self.objects: self.objects['signatures'].append(o) elif 'signature' in self.objects: self.objects['signatures'] = list() n = dict() n['signature'] = self.objects.pop('signature') if 'protected' in self.objects: n['protected'] = self.objects.pop('protected') if 'header' in self.objects: n['header'] = self.objects.pop('header') if 'valid' in self.objects: n['valid'] = self.objects.pop('valid') self.objects['signatures'].append(n) self.objects['signatures'].append(o) else: self.objects.update(o) self.objects['b64'] = b64
[ "def", "add_signature", "(", "self", ",", "key", ",", "alg", "=", "None", ",", "protected", "=", "None", ",", "header", "=", "None", ")", ":", "if", "not", "self", ".", "objects", ".", "get", "(", "'payload'", ",", "None", ")", ":", "raise", "Inval...
Adds a new signature to the object. :param key: A (:class:`jwcrypto.jwk.JWK`) key of appropriate for the "alg" provided. :param alg: An optional algorithm name. If already provided as an element of the protected or unprotected header it can be safely omitted. :param potected: The Protected Header (optional) :param header: The Unprotected Header (optional) :raises InvalidJWSObject: if no payload has been set on the object, or invalid headers are provided. :raises ValueError: if the key is not a :class:`JWK` object. :raises ValueError: if the algorithm is missing or is not provided by one of the headers. :raises InvalidJWAAlgorithm: if the algorithm is not valid, is unknown or otherwise not yet implemented.
[ "Adds", "a", "new", "signature", "to", "the", "object", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jws.py#L419-L510
train
202,896
latchset/jwcrypto
jwcrypto/jws.py
JWS.serialize
def serialize(self, compact=False): """Serializes the object into a JWS token. :param compact(boolean): if True generates the compact representation, otherwise generates a standard JSON format. :raises InvalidJWSOperation: if the object cannot serialized with the compact representation and `compat` is True. :raises InvalidJWSSignature: if no signature has been added to the object, or no valid signature can be found. """ if compact: if 'signatures' in self.objects: raise InvalidJWSOperation("Can't use compact encoding with " "multiple signatures") if 'signature' not in self.objects: raise InvalidJWSSignature("No available signature") if not self.objects.get('valid', False): raise InvalidJWSSignature("No valid signature found") if 'protected' in self.objects: protected = base64url_encode(self.objects['protected']) else: protected = '' if self.objects.get('payload', False): if self.objects.get('b64', True): payload = base64url_encode(self.objects['payload']) else: if isinstance(self.objects['payload'], bytes): payload = self.objects['payload'].decode('utf-8') else: payload = self.objects['payload'] if '.' in payload: raise InvalidJWSOperation( "Can't use compact encoding with unencoded " "payload that uses the . character") else: payload = '' return '.'.join([protected, payload, base64url_encode(self.objects['signature'])]) else: obj = self.objects sig = dict() if self.objects.get('payload', False): if self.objects.get('b64', True): sig['payload'] = base64url_encode(self.objects['payload']) else: sig['payload'] = self.objects['payload'] if 'signature' in obj: if not obj.get('valid', False): raise InvalidJWSSignature("No valid signature found") sig['signature'] = base64url_encode(obj['signature']) if 'protected' in obj: sig['protected'] = base64url_encode(obj['protected']) if 'header' in obj: sig['header'] = obj['header'] elif 'signatures' in obj: sig['signatures'] = list() for o in obj['signatures']: if not o.get('valid', False): continue s = {'signature': base64url_encode(o['signature'])} if 'protected' in o: s['protected'] = base64url_encode(o['protected']) if 'header' in o: s['header'] = o['header'] sig['signatures'].append(s) if len(sig['signatures']) == 0: raise InvalidJWSSignature("No valid signature found") else: raise InvalidJWSSignature("No available signature") return json_encode(sig)
python
def serialize(self, compact=False): """Serializes the object into a JWS token. :param compact(boolean): if True generates the compact representation, otherwise generates a standard JSON format. :raises InvalidJWSOperation: if the object cannot serialized with the compact representation and `compat` is True. :raises InvalidJWSSignature: if no signature has been added to the object, or no valid signature can be found. """ if compact: if 'signatures' in self.objects: raise InvalidJWSOperation("Can't use compact encoding with " "multiple signatures") if 'signature' not in self.objects: raise InvalidJWSSignature("No available signature") if not self.objects.get('valid', False): raise InvalidJWSSignature("No valid signature found") if 'protected' in self.objects: protected = base64url_encode(self.objects['protected']) else: protected = '' if self.objects.get('payload', False): if self.objects.get('b64', True): payload = base64url_encode(self.objects['payload']) else: if isinstance(self.objects['payload'], bytes): payload = self.objects['payload'].decode('utf-8') else: payload = self.objects['payload'] if '.' in payload: raise InvalidJWSOperation( "Can't use compact encoding with unencoded " "payload that uses the . character") else: payload = '' return '.'.join([protected, payload, base64url_encode(self.objects['signature'])]) else: obj = self.objects sig = dict() if self.objects.get('payload', False): if self.objects.get('b64', True): sig['payload'] = base64url_encode(self.objects['payload']) else: sig['payload'] = self.objects['payload'] if 'signature' in obj: if not obj.get('valid', False): raise InvalidJWSSignature("No valid signature found") sig['signature'] = base64url_encode(obj['signature']) if 'protected' in obj: sig['protected'] = base64url_encode(obj['protected']) if 'header' in obj: sig['header'] = obj['header'] elif 'signatures' in obj: sig['signatures'] = list() for o in obj['signatures']: if not o.get('valid', False): continue s = {'signature': base64url_encode(o['signature'])} if 'protected' in o: s['protected'] = base64url_encode(o['protected']) if 'header' in o: s['header'] = o['header'] sig['signatures'].append(s) if len(sig['signatures']) == 0: raise InvalidJWSSignature("No valid signature found") else: raise InvalidJWSSignature("No available signature") return json_encode(sig)
[ "def", "serialize", "(", "self", ",", "compact", "=", "False", ")", ":", "if", "compact", ":", "if", "'signatures'", "in", "self", ".", "objects", ":", "raise", "InvalidJWSOperation", "(", "\"Can't use compact encoding with \"", "\"multiple signatures\"", ")", "if...
Serializes the object into a JWS token. :param compact(boolean): if True generates the compact representation, otherwise generates a standard JSON format. :raises InvalidJWSOperation: if the object cannot serialized with the compact representation and `compat` is True. :raises InvalidJWSSignature: if no signature has been added to the object, or no valid signature can be found.
[ "Serializes", "the", "object", "into", "a", "JWS", "token", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jws.py#L512-L582
train
202,897
latchset/jwcrypto
jwcrypto/jwt.py
JWT.make_signed_token
def make_signed_token(self, key): """Signs the payload. Creates a JWS token with the header as the JWS protected header and the claims as the payload. See (:class:`jwcrypto.jws.JWS`) for details on the exceptions that may be reaised. :param key: A (:class:`jwcrypto.jwk.JWK`) key. """ t = JWS(self.claims) t.add_signature(key, protected=self.header) self.token = t
python
def make_signed_token(self, key): """Signs the payload. Creates a JWS token with the header as the JWS protected header and the claims as the payload. See (:class:`jwcrypto.jws.JWS`) for details on the exceptions that may be reaised. :param key: A (:class:`jwcrypto.jwk.JWK`) key. """ t = JWS(self.claims) t.add_signature(key, protected=self.header) self.token = t
[ "def", "make_signed_token", "(", "self", ",", "key", ")", ":", "t", "=", "JWS", "(", "self", ".", "claims", ")", "t", ".", "add_signature", "(", "key", ",", "protected", "=", "self", ".", "header", ")", "self", ".", "token", "=", "t" ]
Signs the payload. Creates a JWS token with the header as the JWS protected header and the claims as the payload. See (:class:`jwcrypto.jws.JWS`) for details on the exceptions that may be reaised. :param key: A (:class:`jwcrypto.jwk.JWK`) key.
[ "Signs", "the", "payload", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwt.py#L416-L428
train
202,898
latchset/jwcrypto
jwcrypto/jwt.py
JWT.make_encrypted_token
def make_encrypted_token(self, key): """Encrypts the payload. Creates a JWE token with the header as the JWE protected header and the claims as the plaintext. See (:class:`jwcrypto.jwe.JWE`) for details on the exceptions that may be reaised. :param key: A (:class:`jwcrypto.jwk.JWK`) key. """ t = JWE(self.claims, self.header) t.add_recipient(key) self.token = t
python
def make_encrypted_token(self, key): """Encrypts the payload. Creates a JWE token with the header as the JWE protected header and the claims as the plaintext. See (:class:`jwcrypto.jwe.JWE`) for details on the exceptions that may be reaised. :param key: A (:class:`jwcrypto.jwk.JWK`) key. """ t = JWE(self.claims, self.header) t.add_recipient(key) self.token = t
[ "def", "make_encrypted_token", "(", "self", ",", "key", ")", ":", "t", "=", "JWE", "(", "self", ".", "claims", ",", "self", ".", "header", ")", "t", ".", "add_recipient", "(", "key", ")", "self", ".", "token", "=", "t" ]
Encrypts the payload. Creates a JWE token with the header as the JWE protected header and the claims as the plaintext. See (:class:`jwcrypto.jwe.JWE`) for details on the exceptions that may be reaised. :param key: A (:class:`jwcrypto.jwk.JWK`) key.
[ "Encrypts", "the", "payload", "." ]
961df898dc08f63fe3d900f2002618740bc66b4a
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jwt.py#L430-L442
train
202,899