You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> signer_kwargs = dict(log_requests=True) # will log the request url and response data when retrieving
348
410
>>> auth = ads.auth.create_signer(signer_callable=signer_callable, signer_kwargs=signer_kwargs) # instance principals authentication dictionary created based on callable with kwargs parameters
"Some error happened during auto-refreshing the token. Continue using the current one that's expiring in less than {SECURITY_TOKEN_LEFT_TIME} seconds."
873
+
"Please follow steps in https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/clitoken.htm to renew token."
Copy file name to clipboardExpand all lines: docs/source/user_guide/cli/authentication.rst
+27-5Lines changed: 27 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -62,13 +62,28 @@ You can choose to use the instance principal to authenticate while using the Acc
62
62
mc = ModelCatalog(compartment_id="<compartment_id>")
63
63
mc.list_models()
64
64
65
+
4. Authenticating Using Security Token
66
+
--------------------------------------
65
67
66
-
4. Overriding Defaults
68
+
**Prerequisite**
69
+
70
+
* You have setup security token as per the instruction `here <https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/clitoken.htm>`_
71
+
72
+
You can choose to use the security token to authenticate while using the Accelerated Data Science (ADS) SDK by running ``ads.set_auth(auth='security_token')``. For example:
73
+
74
+
.. code-block:: python
75
+
76
+
import ads
77
+
ads.set_auth(auth='security_token')
78
+
mc = ModelCatalog(compartment_id="<compartment_id>")
79
+
mc.list_models()
80
+
81
+
5. Overriding Defaults
67
82
----------------------
68
83
69
84
The default authentication that is used by ADS is set with the ``set_auth()`` method. However, each relevant ADS method has an optional parameter to specify the authentication method to use. The most common use case for this is when you have different permissions in different API keys or there are differences between the permissions granted in the resource principals and your API keys.
70
85
71
-
By default, ADS uses API keys to sign requests to OCI resources. The ``set_auth()`` method is used to explicitly set a default signing method. This method accepts one of three strings ``"api_key"``, ``"resource_principal"``, or ``instance_principal``.
86
+
By default, ADS uses API keys to sign requests to OCI resources. The ``set_auth()`` method is used to explicitly set a default signing method. This method accepts one of four strings ``"api_key"``, ``"resource_principal"``, ``instance_principal`` or ``security_token``.
72
87
73
88
The ``~/.oci/config`` configuration allow for multiple configurations to be stored in the same file. The ``set_auth()`` method takes is ``oci_config_location`` parameter that specifies the location of the configuration, and the default is ``"~/.oci/config"``. Each configuration is called a profile, and the default profile is ``DEFAULT``. The ``set_auth()`` method takes in a parameter ``profile``. It specifies which profile in the ``~/.oci/config`` configuration file to use. In this context, the ``profile`` parameter is only used when API keys are being used. If no value for ``profile`` is specified, then the ``DEFAULT`` profile section is used.
74
89
@@ -97,6 +112,7 @@ The ``~/.oci/config`` configuration allow for multiple configurations to be stor
97
112
98
113
ads.set_auth("resource_principal") # default signer is set to resource principal authentication
99
114
ads.set_auth("instance_principal") # default signer is set to instance principal authentication
115
+
ads.set_auth("security_token") # default signer is set to security token authentication
In the this example, the default authentication uses API keys specified with the ``set_auth`` method. However, since the ``os_auth`` is specified to use resource principals, the notebook session uses the resource principal to access OCI Object Store.
130
149
@@ -144,11 +163,14 @@ More signers can be created using the ``create_signer()`` method. With the ``aut
144
163
# Example 1. Create signer that uses instance principals
0 commit comments