Scope Parsing¶
Scope parsing is handled by the ScopeParser
type.
Additionally, Scope
objects define a
parse()
method which wraps parser
usage.
ScopeParser
provides classmethods as its primary interface, so there
is no need to instantiate the parser in order to use it.
ScopeParser Reference¶
- class globus_sdk.scopes.ScopeParser[source]¶
Bases:
object
The
ScopeParser
handles the conversion of strings to scopes.Most interfaces are classmethods, meaning users should prefer usage like
ScopeParser.parse("foo")
- classmethod merge_scopes(scopes_a, scopes_b)[source]¶
Given two lists of Scopes, merge them into one list of Scopes by parsing them as one combined scope string.
- classmethod parse(scope_string)[source]¶
Parse an arbitrary scope string to a list of scopes.
Zero or more than one scope may be returned, as in the case of an empty string or space-delimited scopes.
Warning
Parsing passes through an intermediary representation which treats scopes as a graph. This ensures that the behavior of parses matches the treatment of scope strings in Globus Auth authorization flows. However, this also means that the parsing does not allow for strings which represent consent trees with structures in which the same scope appears in multiple parts of the tree.
- classmethod serialize(scopes, *, reject_empty=True)[source]¶
Normalize scopes to a space-separated scope string.
The results of this method are suitable for sending to Globus Auth. Scopes are not parsed, merged, or normalized by this method.
- Parameters:
- Returns:
A space-separated scope string.
- Return type:
Example usage:
>>> ScopeParser.serialize([Scope("foo"), "bar", Scope("qux")]) 'foo bar qux'