WSO2 Identity Server 6.0 unable to find API for retrieve and update challenge questions - wso2-identity-server

1.We are adding the security questions in /_system/config/repository/components/org.wso2.carbon.identity.mgt/questionCollection. We are trying to retrieve those using /me/challenges GET method under Challenge Questions API https://is.docs.wso2.com/en/latest/apis/challenge-rest-api/#/, but we are not able to retrieve them and also update them using GET and PUT API's. Is there any way to retrieve these questions which are added under this directory/_system/config/repository/components/org.wso2.carbon.identity.mgt/questionCollection and also update them??

As per the description, seems you want to manage the question sets and their questions stored in the server.
Use the following REST APIs to retrieve the question sets stored in /_system/config/identity/questionCollection location and update those question sets.
https://github.com/wso2/identity-api-server/blob/master/components/org.wso2.carbon.identity.api.server.challenge/org.wso2.carbon.identity.rest.api.server.challenge.v1/src/main/resources/challenge.yaml
GET challenge questions grouped by question set id:
curl --location --request GET 'https://localhost:9443/api/server/v1/challenges' \
--header 'Accept: application/json' \
--header 'Authorization: Basic YWRtaW46YWRtaW4='
Update questions in one set:
eg: PUT request to replace all questions in challengeQuestion2 set
curl --location --request PUT 'https://localhost:9443/api/server/v1/challenges/challengeQuestion2' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data-raw '[
{
"locale": "en_US",
"question": "Name of the hospital where you were born ?",
"questionId": "question2"
},
{
"locale": "en_US",
"question": "Model of your first car ?",
"questionId": "question1"
}
]'
eg: PATCH request to ADD one question to challengeQuestion2 set
curl --location --request PATCH 'https://localhost:9443/api/server/v1/challenges/challengeQuestion2' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data-raw '{
"operation": "ADD",
"challengeQuestion": {
"question": "what is your school",
"locale": "en_US",
"questionId": "question9"
}
}'
https://is.docs.wso2.com/en/latest/apis/challenge-rest-api/#/ this REST API is used to manage the challenge questions answers. /me/challenges and /{user-id}/challenges APIs are there to list out what are the available questions for the user to answer.

Related

Getting {"error": "invalid_grant" } in Django OAUTH when trying to generate a token using AUTHORIZATION CODE FLOW

I'm trying to access token using authorization code flow. I'm using authorization_code as the grant type.
Following documentation at Django OAuth
Here's my code that's making the post request:
curl --location --request POST 'http://127.0.0.1:8000/o/token/' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cache-Control: no-cache' \
--header 'Accept: application/json' \
--data-urlencode 'client_id=ngta3GGa3jP6Rmv5Tspj97Bk4aiitHgv1EQilCDS' \
--data-urlencode 'client_secret=zLwMyuXg7WCSFwUDYBxFP3QxHh5mF6xM2hBsKyvRbypac5lV7fl2NoFeeDG3afWWxLedA7qtzD2Mvf68qyBra3A4iUXXlDXJO4LvxuZv4UULU6NLWlObpD0ylQSXbwZD' \
--data-urlencode 'code=q4NfBMbyTNbcIQZ4j7SfgMWL898psv' \
--data-urlencode 'redirect_uri=http://localhost:8000/no/callback/' \
--data-urlencode 'code_verifier=b'\''SlJDWEgyRzNYMks0RTVQVDlRVkFaOFdDUkxHV1A3QURMTjNITFdaMTBLU0tWQkkzMUVWVEZFU0k='\''' \
--data-urlencode 'grant_type=authorization_code'
I'm expecting to get an access token when I make the post request, but I'm getting this error:
{
"error": "invalid_grant"
}
The grant is valid i.e not expired. Server time is in sync with machine time. Expiry time is 5 minutes but doesnt work even before it's expired.

"Invalid param: not a Token account" when trying to obtain the balance of USDT account in Solana

I'm trying to get the balance of a random USDT account in Solana. I've tried several public gateways and hasn't successed. Here's one example:
curl --request POST \
--url https://solana-mainnet.g.alchemy.com/v2/demo \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "getTokenAccountBalance",
"params": [
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
]
}
'
===>
{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid param: not a Token account"},"id":1}
Why is it "not a token account"? What's the matter?
Here's an account - https://solscan.io/account/TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
update 1
this address won't work either, resulting in the same error:
5Xm6nU1Bi6UewCrhJQFk1CAV97ZJaRiFw4tFNhUbXy3u
TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA is the Token Program itself and not a token account. This is a token account:
https://solscan.io/account/2SYZWm9WeCXb7LBX7dqXgk1dfF5Xa7wJobDSLos8urXp

403 Error while creating API through Publisher API in Wso2

i am getting 403 forbideen error for below curl command,
Step1: Get the token
{
"access_token": "*********************c",
"scope": "am_application_scope apim:api_create apim:api_view",
"token_type": "Bearer",
"expires_in": 3600
}
Step 2:
curl --location --request POST 'https://PublisherDNS/api/am/publisher/v1/apis' \
--header 'Authorization: Bearer *************************' \
--header 'Content-Type: application/json' \
--header 'Cookie: JSESSIONID=508DADCDB2B1F4CF8C0E459C838AE10C; requestedURI=../../api/am/publisher/v1/apis' \
--data-raw '{
"name": "PizzaShackAPI",
"description": "This is a simple API for Pizza Shack online pizza delivery store.",
"context": "pizza",
"version": "1.0.0",
} ```
Can you try with v1.0 instead of v1 in your URL? (Also, v0.15 should be working as well)

Error while creating service account in GCP via SDK

I have been using Google's SDKs to perform API calls such as creating a service account, creating service account keys, get the storage buckets, etc.. Recently I'm unable to create a service account due to the below error.
Request:
curl --location --request POST 'https://iam.googleapis.com/v1/projects/myproject/serviceAccounts' \
--header 'Authorization: Bearer <<token>>' \
--header 'Accept-Encoding: gzip' \
--header 'User-Agent: my test Google-API-Java-Client'
c.g.a.c.g.j.GoogleJsonResponseException: 404 Not Found
{
"code" : 404,
"errors" : [ {
"domain" : "global",
"message" : "Not found; Gaia id not found for email xxxxx#myproject.iam.gserviceaccount.com",
"reason" : "notFound"
} ],
"message" : "Not found; Gaia id not found for email xxxxx#myproject.iam.gserviceaccount.com",
"status" : "NOT_FOUND"
}
Why would I require Gaia id while creating service account? Where can I find this id? Any help is appreciated!!
Did you ever remove the service account 'xxxxx#myproject.iam.gserviceaccount.com' which should be the default service account for IAM API, you can recover it within the 30days after the deletion. or just disable it and re-enable it , will recreate the default service account for you. Let me know if it resolved the issue.
It seems that your request needs to have a body
The request body contains data with the following structure:
{
"accountId": string,
"serviceAccount": {
object (ServiceAccount)
}
}
And it is missing in your command.
You can obtain more information in this documentation.
In your case it should be something like:
curl --request POST \
'https://iam.googleapis.com/v1/projects/my-little-project/serviceAccounts?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"accountId":"sa-test","serviceAccount":{"description":"sa-description-test","displayName":"sa-display-testonly"}}' \
--compressed
You can test this API directly in the following link
Also, I have found a similar error, in this stackoverflow case according to this answer this error could be generated if the APIs are not enabled.

GCP IoTCore won't parse payload using Gateways and HTTP bridge

Steps taken so far
Create a new key pair and use it for the gateway that is about to be created
Create a gateway, let's call it 'my_first_gateway'
Create a new device, let's call it 'gw_device_1'
Associate gw_device_1 with my_first_gateway
Works fine so far.
Now I want to use the HTTP bridge to send gw_device_1's state data to IoTCore via my gateway using my_first_gateway's private key, following this tutorial: https://cloud.google.com/iot/docs/how-tos/gateways/http-bridge#setting_device_state_through_the_gateway
Observation1: the URL in this tutorial seems malformatted, there is a missing double quote at the end of 'delegated_device_id':
curl -X POST -H 'authorization: Bearer GATEWAY_JWT' -H 'content-type: application/json' --data '{"binary_data": "DATA", "gateway_info": {"delegated_device_id: "device-id"}}' -H 'cache-control: no-cache' 'https://cloudiotdevice.googleapis.com/v1/projects/{project-id}/locations/{cloud-region}/registries/{registry-id}/devices/{gateway-id}:setState'
When I am now replacing all placeholders and replace "DATA" with say "ewogICJhUHJvcCI6ICJhVmFsdWUiCn0" I execute the following curl (the token is obviously not real):
curl -X POST -H 'authorization: Bearer GW_JWT_TOKEN' -H 'content-type: application/json' --data '{"binary_data": "ewogICJhUHJvcCI6ICJhVmFsdWUiCn0=", "gateway_info": {"delegated_device_id": "gw_device_1"}}' -H 'cache-control: no-cache' 'https://cloudiotdevice.googleapis.com/v1/projects/my_project_id/locations/europe-west1/registries/my_registry/devices/my_first_gateway:setState'
I receive this error:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"binary_data\": Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"binary_data\": Cannot find field."
}
]
}
]
}
}
The fun thing is: There is another 'endpoint' that is used to publish events to IoTCore. It has the same signature but instead of 'setState' it ends with 'publishEvent' (see: https://cloud.google.com/iot/docs/how-tos/gateways/http-bridge#publishing_the_devices_telemetry_events_through_the_gateway).
Executing the exact same request with this method works just fine:
curl -X POST -H 'authorization: Bearer GW_JWT_TOKEN' -H 'content-type: application/json' --data '{"binary_data": "ewogICJhUHJvcCI6ICJhVmFsdWUiCn0=", "gateway_info": {"delegated_device_id": "gw_device_1"}}' -H 'cache-control: no-cache' 'https://cloudiotdevice.googleapis.com/v1/projects/my_project_id/locations/europe-west1/registries/my_registry/devices/my_first_gateway:publishEvent'
Am I missing something?
Any help appreciated.
Actually, the curl that google provides is not correct.
The payload needs to be adapted a bit, the binary_data string needs to be wrapped in an object called 'state'
{ "state": { "binary_data": "ewogICJhUHJvcCI6ICJhVmFsdWUiCn0=" }, "gateway_info": {"delegated_device_id": "gw_device_1"}}
The curl then works as expected.