-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SK-1731: Added service account samples and vault api samples
- Loading branch information
1 parent
c73aa65
commit 1e40d2f
Showing
19 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
samples/service_account/scoped_token_generation_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired | ||
|
||
file_path = 'CREDENTIALS_FILE_PATH' | ||
bearer_token = '' | ||
|
||
skyflow_credentials_string = '{"clientID":"<YOUR_CLIENT_ID>","clientName":"<YOUR_CLIENT_NAME>","tokenURI":"<YOUR_TOKEN_URI>","keyID":"<YOUR_KEY_ID>","privateKey":"<YOUR_PRIVATE_KEY>"}' | ||
|
||
|
||
# Generate bearer token from credentials file path | ||
options = { | ||
"ctx": "<CONTEXT_ID>" | ||
} | ||
|
||
if is_expired(bearer_token): | ||
bearer_token, token_type = generate_bearer_token( | ||
"<YOUR_CREDENTIALS_FILE_PATH>", options | ||
) | ||
|
||
print(bearer_token, token_type) | ||
|
||
|
||
# Generate bearer token from credentials string | ||
if is_expired(bearer_token): | ||
bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string, options) | ||
|
||
print(bearer_token, token_type) | ||
|
27 changes: 27 additions & 0 deletions
27
samples/service_account/signed_token_generation_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from skyflow.service_account import is_expired, generate_signed_data_tokens, generate_signed_data_tokens_from_creds | ||
|
||
file_path = 'CREDENTIALS_FILE_PATH' | ||
bearer_token = '' | ||
|
||
skyflow_credentials_string = '{"clientID":"<YOUR_CLIENT_ID>","clientName":"<YOUR_CLIENT_NAME>","tokenURI":"<YOUR_TOKEN_URI>","keyID":"<YOUR_KEY_ID>","privateKey":"<YOUR_PRIVATE_KEY>"}' | ||
|
||
|
||
|
||
options = { | ||
"ctx": "CONTEX_ID", | ||
"data_tokens": ["DATA_TOKEN1", "DATA_TOKEN2"], | ||
"time_to_live": 90 # in seconds | ||
} | ||
|
||
# Generate bearer token from credentials file path | ||
if is_expired(bearer_token): | ||
actual_token, signed_token = generate_signed_data_tokens( | ||
"<YOUR_CREDENTIALS_FILE_PATH>", options | ||
) | ||
|
||
|
||
# Generate bearer token from credentials string | ||
if is_expired(bearer_token): | ||
actual_token, signed_token = generate_signed_data_tokens_from_creds( | ||
"<CREDENTIALS_STRING>", options | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired | ||
|
||
file_path = 'CREDENTIALS_FILE_PATH' | ||
bearer_token = '' | ||
|
||
skyflow_credentials_string = '{"clientID":"<YOUR_CLIENT_ID>","clientName":"<YOUR_CLIENT_NAME>","tokenURI":"<YOUR_TOKEN_URI>","keyID":"<YOUR_KEY_ID>","privateKey":"<YOUR_PRIVATE_KEY>"}' | ||
|
||
|
||
# Generate bearer token from credentials file path | ||
if is_expired(bearer_token): | ||
bearer_token, token_type = generate_bearer_token( | ||
"<YOUR_CREDENTIALS_FILE_PATH>" | ||
) | ||
|
||
print(bearer_token, token_type) | ||
|
||
|
||
# Generate bearer token from credentials string | ||
if is_expired(bearer_token): | ||
bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string) | ||
|
||
print(bearer_token, token_type) | ||
|
26 changes: 26 additions & 0 deletions
26
samples/service_account/token_generation_with_context_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from skyflow.service_account import generate_bearer_token, generate_bearer_token_from_creds, is_expired | ||
|
||
file_path = 'CREDENTIALS_FILE_PATH' | ||
bearer_token = '' | ||
|
||
skyflow_credentials_string = '{"clientID":"<YOUR_CLIENT_ID>","clientName":"<YOUR_CLIENT_NAME>","tokenURI":"<YOUR_TOKEN_URI>","keyID":"<YOUR_KEY_ID>","privateKey":"<YOUR_PRIVATE_KEY>"}' | ||
|
||
|
||
# Generate bearer token from credentials file path | ||
options = { | ||
"role_ids": ["ROLE_ID1", "ROLE_ID2"] | ||
} | ||
if is_expired(bearer_token): | ||
bearer_token, token_type = generate_bearer_token( | ||
"<YOUR_CREDENTIALS_FILE_PATH>", options | ||
) | ||
|
||
print(bearer_token, token_type) | ||
|
||
|
||
# Generate bearer token from credentials string | ||
if is_expired(bearer_token): | ||
bearer_token, token_type = generate_bearer_token_from_creds(skyflow_credentials_string, options) | ||
|
||
print(bearer_token, token_type) | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from ._utils import generate_bearer_token, generate_bearer_token_from_creds, is_expired | ||
from ._utils import generate_bearer_token, generate_bearer_token_from_creds, is_expired, generate_signed_data_tokens, generate_signed_data_tokens_from_creds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters