Keystone v3 auth error - list

I am following keystone ocata installation guide https://docs.openstack.org/ocata/install-guide-ubuntu/keystone-install.html
Post installation, I am able to get the user list using openstack user list command.
openstack --os-auth-url="[keystone_url]" --os-identity-api-version="3" --os-password="mypwd123" --os-project-domain-name="Default" --os-project-name="admin" --os-username="admin" --os-user-domain-name="Default" user list
Outputs the User list properly.
But when I take auth token with below command :
curl -si -d '{"auth": {"identity": {"methods": ["password" ],"password": {"user": {"domain": {"id": "default" },"name": "admin","password": "mypwd123" }}}}}' -H "Content-type: application/json" [keystone_url]/v3/auth/tokens
and then use the token from the output of above command in below command to list the users:
curl -s -H "X-Auth-Token: gAAAAABZlAN0NPibgBLcUW3aAcgNYIGaRH98M7w6b4tRliXC4LQB4dr5cGxTJmF5-iKvY2U_AU3c71uJUqgaQJP-iyURCBzBqYHlHtTGqofzzVndVncBRU5z4iLbArBdbJCI2Wd-1No9C0cq4iWB6RBNa9wqXWm-Gw" "[keystone_url]/v3/users" | python -mjson.tool
Returns :
{
"error": {
"code": 403,
"message": "You are not authorized to perform the requested action: identity:list_users.",
"title": "Forbidden"
}
}
Any help would be appreciated.
Thanks,
Viral

because list users need token with scope, you should add scope for query, like this:
curl -i http://ip:5000/v3/auth/tokens -H "Content-
Type: application/json" -d '
{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": "admin",
"domain": {
"name": "Default"
},
"password": "secret"
}
}
},
"scope": {
"domain": {
"id": "default"
}
}
}
}'
then use X-Subject-Token to query users.
See the official documentation for details.https://docs.openstack.org/keystone/pike/api_curl_examples.html#tokens

Related

Using google app script to send a message with my PMS's API

Im using google app script to hopefully sent a message to my guests using my PMS (Smoobu). I think I have an issue with my syntax.
var smoobuPostOptions = {
"method": 'post',
"muteHttpExceptions": false,
"headers": {
"Api-Key": "???????????????????????????????????",
"cache-control": "no-cache",
"ContentType": "application/json",
},
"data": {
"subject": "Test Subject",
"messageBody": "Test Message"
}
}
var txTresponse = UrlFetchApp.fetch("https://login.smoobu.com/api/reservations/31418467/messages/send-message-to-guest", smoobuPostOptions);
var txtData = JSON.parse(txTresponse.getContentText());
The error I am getting is:
Exception: Request failed for https://login.smoobu.com returned code 500. Truncated server response: {"status":500,"title":"Internal Server Error","detail":"Zend\Form\Form::setData expects an array or Traversable argument; received "NULL""} (use muteHttpExceptions option to examine full response)
API Docs - https://docs.smoobu.com/#send-message-to-guest
I do believe I just need an example and I will be able to work it out!
From your provided document, it seems that you wanted to convert the following curl command to Google Apps Script.
curl -X POST \
'https://login.smoobu.com/api/reservations/1/messages/send-message-to-guest' \
-H 'Api-Key: secretApiKey' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{"subject" : "Test subject","messageBody" : "test"}'
In this case, how about the following modification?
From:
var smoobuPostOptions = {
"method": 'post',
"muteHttpExceptions": false,
"headers": {
"Api-Key": "???????????????????????????????????",
"cache-control": "no-cache",
"ContentType": "application/json",
},
"data": {
"subject": "Test Subject",
"messageBody": "Test Message"
}
}
To:
var smoobuPostOptions = {
"method": 'post',
"headers": {
"Api-Key": "???????????????????????????????????",
"cache-control": "no-cache",
},
"contentType": "application/json",
"payload": JSON.stringify({
"subject": "Test Subject",
"messageBody": "Test Message"
})
};
Note:
I think that the request of the above-modified script is the same as the sample curl command. But, if an error occurs, please confirm your endpoint, "Api-Key" and the request body again.
Reference:
fetch(url, params)

Required field is invalid error when trying to create new dataset in GCP AutoML object detection

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.

Accessing Google Cloud speech-to-text response

I am a total beginner with this and I hope someone can point me into the right direction: I used the Google Cloud Speech-to-text API, in particular the longrunningrecognize method. Now everything works out and I get the expected results:
{
"name": "4983661747957213554",
"metadata": {
"#type":
"type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeMetadata",
"progressPercent": 100,
"startTime": "2019-04-07T10:22:26.018723Z",
"lastUpdateTime": "2019-04-07T10:23:17.659732Z"
},
"done": true
}
After this have been stuck for a full day though. The transcription is done, but how do I access it? Which variable can I call to see the result? How can I save it to a file?
On top, I am wondering what´s the best way to run Python scripts in GCP.
I have seen this answer: Google cloud speech API response : Parsing iOS
but it brings me to a very fundamental problem that I am experiencing: How and where is the best way to execute that code?
I have also tried to create *.py files and chmod them, but is there any easier way to run simple scripts?
My expected result is the final text file or even just access to a string that is behind the operations: that I get returned.
Google has examples in documentation:
In shell, you can run
curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
"https://speech.googleapis.com/v1/operations/4983661747957213554"
Where 4983661747957213554 is the name of your operation returned above. And it will print you the results:
{
"name": "7612202767953098924",
"metadata": {
"#type": "type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeMetadata",
"progressPercent": 100,
"startTime": "2017-07-20T16:36:55.033650Z",
"lastUpdateTime": "2017-07-20T16:37:17.158630Z"
},
"done": true,
"response": {
"#type": "type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeResponse",
"results": [
{
"alternatives": [
{
"transcript": "okay so what am I doing here...(etc)...",
"confidence": 0.96096134,
}
]
},
{
In Python you can run the demo script.

Flink rest api error: Request did not match expected format JarRunRequestBody

Trying to run a flink job remotely using the below rest api but its throwing error
curl -X POST -H 'Content-Type: application/json' --data '
{
"type": "object",
"id": "urn:jsonschema:org:apache:flink:runtime:webmonitor:handlers:JarRunRequestBody",
"properties": {
"programArgsList" : {
"type" : "array",
"items" : [
"input-kafka-server": "****",
"input-kafka-topics": "****",
"input-job-name": "****"
}
}
}
' http://x.x.x.x:8081/jars/810ac968-5d5f-450d-aafc-22655238d617.jar/run
{"errors":["Request did not match expected format JarRunRequestBody."]}
The description of the request body for the jar run handler you find here is the JSON schema specification of the jar run message. What you need to specify in your request are only the properties and not the "type" and "id" fields. Thus, your request should look like:
curl -X POST -H 'Content-Type: application/json' --data '
{
"programArgsList" : [
"--input-kafka-server",
"value-input-kafka-server",
"--input-kafka-topics",
"value-kafka-topics",
"--input-job-name",
"value-job-name"
],
"parallelism": 30
}
' http://x.x.x.x:8081/jars/810ac968-5d5f-450d-aafc-22655238d617.jar/run
If anyone is looking for Python code to submit Flink job through REST API.
import json
url = base_url + "/jars/" + jar_id + "/run"
myheader = {'content-type': 'application/json'}
mydata = {
"programArgsList": [
"--input-kafka-server", "value-input-kafka-server",
"--input-kafka-topics", "value-kafka-topics",
"--input-job-name","value-job-name"
],
"parallelism": 30
}
x = requests.post(url, data=json.dumps(mydata), headers=myheader)

Why does the WSO2 IS 5.6.0 SCIM2 Group API throw error when trying to insert or update users?

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