Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import datetime

import globus_sdk
from globus_sdk.experimental.globus_app import UserApp

# Tutorial Client ID - <replace this with your own client>
NATIVE_CLIENT_ID = "61338d24-54d5-408f-a10d-66c06b59f6d2"
Expand Down Expand Up @@ -35,7 +34,7 @@
},
)

with UserApp("manage-timers-example", client_id=NATIVE_CLIENT_ID) as app:
with globus_sdk.UserApp("manage-timers-example", client_id=NATIVE_CLIENT_ID) as app:
# create a TimersClient to interact with the service, and register any data_access
# scopes for the collections
with globus_sdk.TimersClient(app=app) as timers_client:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import datetime

import globus_sdk
from globus_sdk.experimental.globus_app import UserApp

# Tutorial Client ID - <replace this with your own client>
NATIVE_CLIENT_ID = "61338d24-54d5-408f-a10d-66c06b59f6d2"
Expand Down Expand Up @@ -46,7 +45,7 @@ def uses_data_access(client: globus_sdk.TransferClient, collection_id: str) -> b
)


with UserApp("manage-timers-example", client_id=NATIVE_CLIENT_ID) as app:
with globus_sdk.UserApp("manage-timers-example", client_id=NATIVE_CLIENT_ID) as app:
# as with an immediate data transfer, we take our input data and wrap them in
# a TransferData object, representing the transfer task
transfer_request = globus_sdk.TransferData(SRC_COLLECTION, DST_COLLECTION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
DST_PATH = "/~/example-transfer-script-destination.txt"


def main():
def main() -> None:
with UserApp("my-simple-transfer", client_id=NATIVE_CLIENT_ID) as app:
with globus_sdk.TransferClient(app=app) as client:
submit_transfer(client)


def submit_transfer(transfer_client: globus_sdk.TransferClient):
def submit_transfer(transfer_client: globus_sdk.TransferClient) -> None:
# Comment out each of these lines if the referenced collection is either
# (1) A guest collection or (2) high assurance.
transfer_client.add_app_data_access_scope(SRC_COLLECTION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
DST_PATH = "/~/example-transfer-script-destination.txt"


def main():
def main() -> None:
with UserApp(
"my-simple-transfer",
client_id=NATIVE_CLIENT_ID,
Expand All @@ -25,7 +25,7 @@ def main():
submit_transfer(client)


def submit_transfer(transfer_client: globus_sdk.TransferClient):
def submit_transfer(transfer_client: globus_sdk.TransferClient) -> None:
transfer_request = globus_sdk.TransferData(SRC_COLLECTION, DST_COLLECTION)
transfer_request.add_item(SRC_PATH, DST_PATH)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,38 @@ def _concat(values: list[list[str] | None]) -> list[str] | None:


if __name__ == "__main__":
import typing as t

def to_gare(data: t.Any) -> globus_sdk.gare.GARE:
"""
to_gare() returns None if coercion fails; this wrapper treats that as an error
instead, for nicer types
"""
g = globus_sdk.gare.to_gare(data)
if g is None:
raise ValueError(f"data unexpectedly did not validate as a GARE: {data!r}")
return g

# these are example errors
case1 = globus_sdk.gare.to_gare(
case1 = to_gare(
{
"code": "ConsentRequired",
"authorization_parameters": {"required_scopes": ["foo"]},
}
)
case2 = globus_sdk.gare.to_gare(
case2 = to_gare(
{
"code": "ConsentRequired",
"authorization_parameters": {"required_scopes": ["bar"]},
}
)
case3 = globus_sdk.gare.to_gare(
case3 = to_gare(
{
"code": "AuthorizationRequired",
"authorization_parameters": {"required_scopes": ["baz"]},
}
)
case4 = globus_sdk.gare.to_gare(
case4 = to_gare(
{
"code": "AuthorizationRequired",
"authorization_parameters": {
Expand All @@ -119,7 +131,7 @@ def _concat(values: list[list[str] | None]) -> list[str] | None:
},
}
)
case5 = globus_sdk.gare.to_gare(
case5 = to_gare(
{
"code": "AuthorizationRequired",
"authorization_parameters": {
Expand All @@ -131,7 +143,7 @@ def _concat(values: list[list[str] | None]) -> list[str] | None:
},
}
)
case6 = globus_sdk.gare.to_gare(
case6 = to_gare(
{
"code": "AuthorizationRequired",
"authorization_parameters": {
Expand All @@ -140,7 +152,7 @@ def _concat(values: list[list[str] | None]) -> list[str] | None:
},
}
)
case7 = globus_sdk.gare.to_gare(
case7 = to_gare(
{
"code": "AuthorizationRequired",
"authorization_parameters": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def print_ls_data(client):
print("An authorization requirement was not met. Logging in again...")

gare = globus_sdk.gare.to_gare(err)
if not gare:
raise
params = gare.authorization_parameters
# set 'prompt=login', which guarantees a fresh login without
# reliance on the browser session
Expand Down
Loading