How can I create a new Managed Notebook programmatically?
I want to use Notebooks API REST but has not found an example.
Reference Link
To create a new Managed notebook you can use the following example:
BASE_ADDRESS=notebooks.googleapis.com
LOCATION=us-central1
PROJECT_ID=gogasca-sandbox
AUTH_TOKEN=$(gcloud auth application-default print-access-token)
RUNTIME_BODY="{
'access_config': {
'access_type': 'SINGLE_USER',
'runtime_owner': 'gogasca#google.com'
},
'virtual_machine': {
'virtual_machine_config': {
'data_disk': {
'initialize_params': {
'disk_size_gb': 200,
'disk_type': 'PD_SSD',
}
},
'container_images': [{
'repository': 'gcr.io/deeplearning-platform-release/pytorch-gpu', 'tag': 'latest'
}],
'metadata': {
'file_to_load_1':'https://test.google.com/v2/models/versions/trainable_v1.0/zip',
},
'machine_type':'n1-standard-4',
'accelerator_config': {
'type': 'NVIDIA_TESLA_T4',
'core_count': '1'
}
}
},
'software_config':{
'post_startup_script':'gs://gcp-scripts/step01.sh'
}
}"
RUNTIME_NAME=gogasca-managed-notebook
curl -X POST https://${BASE_ADDRESS}/v1/projects/$PROJECT_ID/locations/$LOCATION/runtimes?runtime_id=$RUNTIME_NAME -d "${RUNTIME_BODY}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AUTH_TOKEN" -v
Google Cloud SDK is in progress.
Terraform module just got released.
Related
We have a bucket in Google Cloud Platform to manage pictures.
I am trying to upload a picture to it using Curl.
Respective to the official documentation linked here, this is the Curl-command I used:
curl -X POST --data-binary #cat.jpeg \
-H "Authorization: Bearer A_STRING_SUPPOSED_TO_BE_A_KEY" \
-H "Content-Type: image/jpeg" \
"https://storage.googleapis.com/upload/storage/v1/b/upload_zone/o?uploadType=media&name=cat"
This is the answer we get:
{
"error": {
"code": 401,
"message": "Invalid Credentials",
"errors": [
{
"message": "Invalid Credentials",
"domain": "global",
"reason": "authError",
"locationType": "header",
"location": "Authorization"
}
]
}
}
It seems our key is invalid, we are not sure what to use as Authorization key. Where can we find the OAUTH2.0-key required to make use of the Google Cloud Platform Bucket, do we need to generate it somewhere?
Edit:
We have generated a key using the OAuth 2.0-Playground, and it worked! But the key expires every 3000 seconds...
If you are already authenticated to Google using the gcloud sdk, you can get the key like this:
-H "Authorization: Bearer $(gcloud auth print-identity-token)"
So, using your example above, this should work:
curl -X POST --data-binary #cat.jpeg \
-H "Authorization: Bearer $(gcloud auth print-identity-token)" \
-H "Content-Type: image/jpeg" \
"https://storage.googleapis.com/upload/storage/v1/b/upload_zone/o?uploadType=media&name=cat"
I know of two ways to authenticate as a user and obtain the access token, one is through the Hosted UI and another with various provided SDKs.
What I'm looking for is an endpoint obtain the access token directly with user credentials.
POST https://that-special-endpoint.com/login
{
username: "example#email.com",
password: "Abc123456",
...client ID, etc.
}
I've searched for some time but could not find how to do this. Is this not possible due to some security concerns that I'm not aware of?
I did consider creating a Lambda API and make use of the Cognito SDK to cater for my use case but I'm not sure if it's advisable...
Similar question is answered here. You can access https://cognito-idp.[region].amazonaws.com/ to call InitiateAuth and RespondToAuthChallenge APIs.
InitiateAuth
Create a json file, aws-auth-data.json
{
"AuthParameters": {
"USERNAME": "your-email#example.com",
"PASSWORD": "your-first-password",
"SECRET_HASH": "......(required if the app client is configured with a client secret)"
},
"AuthFlow": "USER_PASSWORD_AUTH",
"ClientId": "5m........................"
}
Send a request on https://cognito-idp.us-east-2.amazonaws.com/ (if the user pool is on us-east-2 region) to call InitiateAuth API and initiate an authentication flow.
curl -X POST --data #aws-auth-data.json \
-H 'X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth' \
-H 'Content-Type: application/x-amz-json-1.1' \
https://cognito-idp.us-east-2.amazonaws.com/
Then you'll get the user's tokens.
{
"AuthenticationResult": {
"AccessToken": "eyJra........",
"ExpiresIn": 3600,
"IdToken": "eyJra........",
"RefreshToken": "eyJjd........",
"TokenType": "Bearer"
},
"ChallengeParameters": {}
}
RespondToAuthChallenge
You may get a challenge as InitiateAuth response. For example, you will be asked to change password when you make a first 'InitiateAuth' attempt:
{
"ChallengeName": "NEW_PASSWORD_REQUIRED",
"ChallengeParameters": {
"USER_ID_FOR_SRP": "abababab-......",
"requiredAttributes": "[]",
"userAttributes": "{\"email_verified\":\"true\",\"email\":\"your-email#example.com\"}"
},
"Session": "DNdY......"
}
In this case, change the password with RespondToAuthChallenge and you will get tokens.
{
"ChallengeName": "NEW_PASSWORD_REQUIRED",
"ChallengeResponses": {
"USERNAME": "your-email#example.com",
"NEW_PASSWORD": "your-second-password"
},
"ClientId": "5m........................",
"Session": "DNdYN...(what you got in the preceding response)"
}
curl -X POST --data #aws-change-password.json \
-H 'X-Amz-Target: AWSCognitoIdentityProviderService.RespondToAuthChallenge' \
-H 'Content-Type: application/x-amz-json-1.1' \
https://cognito-idp.us-east-2.amazonaws.com/
See also:
https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_InitiateAuth.html
https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_RespondToAuthChallenge.html
https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-authentication-flow.html#amazon-cognito-user-pools-client-side-authentication-flow
I am following the quickstart for AutoML object detection. Unfortunately I run into an error I cannot figure out. At the very first curl command
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
"https://automl.googleapis.com/v1beta1/projects/$PROJECT_ID/locations/us-central1/datasets" -d '{
"display_name": "dataset_name",
"image_object_detection_dataset_metadata": {
}
}'
I get this error:
{
"error": {
"code": 400,
"message": "List of found errors:\t1.Field: parent; Message: Required field is invalid\t",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "parent",
"description": "Required field is invalid"
}
]
}
]
}
}
It seems to be some kind of schema validation error, so perhaps they changed the request body format but I cannot figure out how to change it.
Doh, It turns out the PROJECT_ID variable was not actually set.
It's somewhat typical of GCP that you get very cryptic errors sometimes when working through their APIs.
I'm trying to use the WSO2 Identity Server SCIM2 APIs to create and update users and groups.
However I am facing problems with the Group Update API (PUT /scim2/Groups/{id}): If I try to insert some user into the body of the message, the API always returns HTTP Error 500 ("Error occurred while accessing Java Security Manager Privilege Block ").
Here's how to reproduce the failure:
1) First we create a user:
curl -X POST \
https://auth-server:9444/scim2/Users/ \
-H 'Accept: */*' \
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: a43e26c0-fb00-4fa0-9482-74f62078d6b1' \
-H 'cache-control: no-cache' \
-d '{
"emails": [{
"type": "home",
"value": "test.user#test.com.br",
"primary": true
}],
"password": "test.user",
"name": {
"familyName": "Test",
"givenName": "User"
},
"userName": "test.user"
}'
We receive as response HTTP 200 with body:
{
"emails": [
{
"type": "home",
"value": "test.user#test.com.br",
"primary": true
}
],
"meta": {
"created": "2019-01-09T20:41:27Z",
"location": "https://localhost:9444/scim2/Users/14fc39fc-1b0c-4db2-9e3a-bd5c522770bb",
"lastModified": "2019-01-09T20:41:27Z",
"resourceType": "User"
},
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:User",
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
],
"name": {
"familyName": "Test",
"givenName": "User"
},
"id": "14fc39fc-1b0c-4db2-9e3a-bd5c522770bb",
"userName": "test.user"
}
2) Next we create a group:
curl -X POST \
https://auth-server:9444/scim2/Groups/ \
-H 'Accept: */*' \
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 45d2220d-d33d-42ba-8ce5-205646aa2963' \
-H 'cache-control: no-cache' \
-d '{
"displayName": "Application/Test",
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:Group"
]
}'
We receive as response HTTP 200 with body:
{
"displayName": "APPLICATION/Test",
"meta": {
"created": "2019-01-09T20:43:22Z",
"location": "https://localhost:9444/scim2/Groups/7feb0a54-18c5-4265-bdd6-7ceecd96bf0d",
"lastModified": "2019-01-09T20:43:22Z",
"resourceType": "Group"
},
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:Group"
],
"id": "7feb0a54-18c5-4265-bdd6-7ceecd96bf0d"
}
3) When we try to associate the newly created user with the group, we receive an HTTP 500 error. See below:
curl -X PUT \
https://auth-server:9444/scim2/Groups/7feb0a54-18c5-4265-bdd6-7ceecd96bf0d \
-H 'Accept: */*' \
-H 'Authorization: Basic c2NpbS5kY2xvZ2c6c2NpbS5kY2xvZ2c=' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 6db43a33-af40-452e-83eb-40f8d6e3c5e3' \
-H 'cache-control: no-cache' \
-d '{
"displayName": "APPLICATION/Test",
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:Group"
],
"members": [
{
"value": "14fc39fc-1b0c-4db2-9e3a-bd5c522770bb",
"display": "test"
}
]
}'
HTTP 500 error:
{
"schemas": "urn:ietf:params:scim:api:messages:2.0:Error",
"detail": "Error occurred while accessing Java Security Manager Privilege Block",
"status": "500"
}
For authentication, I am using basic authentication, with the user "admin" of Identity Server; but I also tried to create a user with all possible permissions, but the error is always the same.
In the execution console I have tried to refine the log, however only the message below is displayed:
[2019-01-09 20:47:00,656] DEBUG {org.wso2.carbon.user.core.common.AbstractUserStoreManager} - Domain: APPLICATION is passed with the claim and user store manager is loaded for the given domain name.
[2019-01-09 20:47:00,658] ERROR {org.wso2.carbon.user.core.common.AbstractUserStoreManager} - Error occurred while accessing Java Security Manager Privilege Block
Does this Group API really work for update requests?
If anyone can help, I appreciate it. Thank you.
Please change your request of adding a user to a group as follows, this works fine for me.
curl -v -k --user admin:admin -X PUT -d '{"displayName":"PRIMARY/manager","members":[{"value":"416aaa06-d9ed-465b-8ac4-1a321624d158","display":"test.user"}]}' --header "Content-Type:application/json" https://localhost:9444/scim2/Groups/5d6ffce8-fab8-45ee-a407-b1cae0e4ecee
I cannot display my original code in sentry dashboard.
i get the following errors
Discarded invalid parameter 'type'
Source code was not found for app:///crna-entry.delta?
platform=ios&dev=true&minify=false`
I've configured the app.json as indicated in the docs.
"hooks": {
"postPublish": [
{
"file": "sentry-expo/upload-sourcemaps",
"config": {
"organization": "xxxxx",
"project": "xxxxxxx",
"authToken": "xxxxxxxxxx"
}
}
]
}
I answered this question here
First way
If you are using expo. You should use sentry-expo package which you can find here: sentry-expo
Put this hook to your expo json (app.json) file
{
"expo": {
"hooks": {
"postPublish": [
{
"file": "sentry-expo/upload-sourcemaps",
"config": {
"organization": "<your organization name>",
"project": "<your project name>",
"authToken": "<your auth token here>"
}
}
]
}
}
organization you can find on here https://sentry.io/settings/ which named "Organization Name"
project enter your project name, you can find here: https://sentry.io/organizations/ORGANIZATION_NAME/projects/
authToken create a authToken with this url https://sentry.io/api/
Then run expo publish, it upload the source maps automatically.
Testing Locally
Make sure that you enabled expo development.
add lines;
Sentry.enableInExpoDevelopment = true;
Sentry.config(publicDsn, options).install();
As a Result
On sentry, for only ios, you can able to see the source code where error occured.
BUT: unable to see the source code for ANDROID
https://github.com/getsentry/react-native-sentry/issues/372
Second way (manual upload)
Using the api https://docs.sentry.io/platforms/javascript/sourcemaps/
curl -X POST \
https://sentry.io/api/0/organizations/ORG_NAME/releases/VERSION/files/ \
-H 'Authorization: Bearer AUTH_TOKEN' \
-H 'content-type: multipart/form-data' \
-F file=#script.min.js.map \
-F 'name=~/scripts/script.min.js.map'