1

how do I get the CSRF token for a jupyter notebook on Amazon sagemaker studio?

I am running the following command in the notebook named "test.ipynb" on sagemaker studio notebook instance:

import requests
url = https://<id>.studio.<region>.sagemaker.aws/jupyter/default/lab/tree/test.ipynb
response = requests.get(url)

this is giving me response [403].. What am I missing?

Meghana S
  • 75
  • 6

1 Answers1

0

Your request is receiving a 403 response as requests is not authorised.

If you want to access SageMaker Studio via URL, you’ll need to create a pre-signed link.

This is done automatically when launching Studio from the AWS Console or IAM Identity Center, however, the AWS CLI makes this easy with the create-presigned-domain-url command 1.

Depending on your use-case, it may be easier to perform this using boto3, the AWS Python package. Here’s the guide.

fucalost
  • 313
  • 1
  • 8