Comments (2)
Hi there, thanks for reporting this! I believe that you're seeing normal behavior, but for a specific case which the example script doesn't explain.
I need to think more about what we do to improve the docs...
That error is thrown when a collection requires explicit consent for operations to run against it.
There's some utility in the SDK for parsing these errors and making them actionable, but there are still significant parts which you would need to fill in.
First, here's the section on parsing ConsentRequired errors. You can identify them like so:
try:
# do some operations
except globus_sdk.TransferAPIError as err:
if err.info.consent_required:
print(
"Got a ConsentRequired error with scopes:",
err.info.consent_required.required_scopes,
)
else:
raise
That is, once you have caught an API error, check if err.info.consent_required
to see if it's the right type, and if it is, you'll have useful data in required_scopes
.
So far, this is maybe non-obvious but it's "easy enough", but the next step can be difficult for some applications.
You need the user (in this case, you) to do a new login flow with the required_scopes
from above, and then you need to start using the Transfer API token from that login flow.
If your initial login flow was done with a native app like the SDK tutorial shows, you'll probably have a line like so:
auth_client.oauth2_start_flow()
The correct modification is just
# where `required_scopes` is the value we got from exception handling earlier on a
# ConsentRequired error
auth_client.oauth2_start_flow(requested_scopes=required_scopes)
In the globus-cli, the way we've solved this is that tokens are stored using globus_sdk.tokenstorage, and we have a dedicated command (globus session consent
) which updates the tokens which are in storage.
In effect, the globus-cli error handler looks like this:
try:
# do some operations
except globus_sdk.TransferAPIError as err:
if err.info.consent_required:
print("Error: ConsentRequired during Transfer operation")
print("Please run the following command and then try again:")
print()
print(f" globus session consent '{err.info.consent_required.required_scopes}'")
print()
else:
raise
Depending on the exact nature of your code (a script, an application, etc), this may or may not be easy for you to handle in a similar way.
I would recommend that if you are not already using it that you start using globus_sdk.tokenstorage
-- it will probably make it easier for you to follow the pattern we've established with the globus-cli. This example shows some pretty complete usage, so it might be a good jumping-off point for you.
I'm keeping this open because I think we should do something on that example page to document what I've written here. Possibly we should add a second larger example to the same page to handle this case.
from globus-sdk-python.
We have detailed handling examples going out in our next release, and currently visible here:
https://globus-sdk-python.readthedocs.io/en/latest/examples/minimal_transfer_script/index.html
As such, I think we're able to close this as resolved.
from globus-sdk-python.
Related Issues (20)
- Make a user searchable by globus username/email after AuthClient login HOT 2
- Add delete_destination_extra to TransferData documentation
- Feature request: multiple src files transferred to a single dest folder HOT 2
- Support installation with pyinstaller
- automate sharing? HOT 6
- TransferClient.endpoint_manager_task_list has invalid usage as an example
- Update tutorial to indicate how to pass `requested_scopes` and get non-default tokens HOT 5
- Raise the lower bound on `cryptography` in the requirements data
- Note the behavior of tokenstorage adapters on Windows; recommend localappdata
- Paginated methods lose typing information for type-checking HOT 2
- TransferAPIError: Error communicating with Globus Nexus Service HOT 1
- Local endpoint / upload without Globus Personal Connect HOT 3
- Use AuthClient.get_identities() to search by email address? HOT 2
- Confusing __str__() implementation for OAuthTokenResponse HOT 1
- Create a LoginManager object which provides a model for managing authentication HOT 1
- Missing f-string in parameterized url HOT 2
- usage Client Credentials Authentication HOT 1
- Cannot change `limit` in paginated.post_search() HOT 3
- ConsentRequired error HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from globus-sdk-python.