Bearer undefined in wso2 api manager - wso2

I published my API in wso2 API Manager when I tried it out in the developer portal. I got the error Bearer undefined in a curl command.
curl -X GET "https://localhost:8243/meter/1/?ConsumerID=LTFAREERKC&StartDate=01-05-2022 EndDate=02-05-2022" -H "accept: */*" -H "Authorization: Basic QREYUREFBE H: Bearer undefined"

Check the Authorization header you send in the curl command, it must contain "Bearer " and not "Basic ".
Example:
-H "Authorization: Bearer <YOUR-ACCESS-TOKEN>"
Do not forget to generate the Access Token.

Related

Delete feature stores. But, Continue to be charged

I created a "Feature Store" of "Vertex AI" and later deleted it, but it continue to charge as SKU "Feature Store online serving node".
Is there anyone in the same condition?
Has anyone recovered from this condition? How?
I created and deleted a feature store by curl, along with the following documentation.
https://cloud.google.com/vertex-ai/docs/featurestore/managing-featurestores
$ curl -X POST -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) -H "Content-Type: application/json; charset=utf-8" -d #request.json https://us-central1-aiplatform.googleapis.com/v1beta1/projects/xxx/locations/us-central1/featurestores?featurestoreId=used_apartment
$ curl -X DELETE -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) -H "Content-Type: application/json; charset=utf-8" https://us-central1-aiplatform.googleapis.com/v1beta1/projects/xxx/locations/us-central1/featurestores/used_apartment
I checked the list of feature stores list. I received an empty result.
$ curl -X GET -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) https://us-central1-aiplatform.googleapis.com/v1beta1/projects/xxx/locations/us-central1/featurestores
{}
However, I seem to continue to be charged. (Why?)
It seems that the charge stopped during the weekend.
Past charges have also been revised.
I don't know the cause, but the problem is gone, so I will close it.
The overcharge should be temporary and should be reverted 2 days after deleting the feature stores. We are actively working on improving the processing so that you will not see such temporary incorrect charge in the future.

WSO2 Identity Server OAuth2 access token request redirects to login page

I'm trying to send a request to https://{identity-server}:9443/oauth2/token. And the request is redirected to Location: https://{identity-server}:9443/carbon/admin/login.jsp. The version I'm using is IS 5.7.0 and deployed on Kubernetes as a clustered setup.
You are missing the authorization header in the request. That's why you are getting redirected to the login page.
Try to provide the authorization header like this
Authorization: Basic [Base64encode(Client-ID>:<ClientSecret>)]
Final request should be similar to this
curl -X POST \
https://localhost:9443/oauth2/token \
-H 'Authorization: Basic Zkd2ZlhiQ05VeUFmd2ltQW9HSWYycXZDakdFYTpFb1NOWDdHNFQ2NGZjcVFyZTVIX2NPR01CS2Nh' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=admin&password=admin&grant_type=password&scope=bearer'

API Speech to text credentials in google cloud problem

I'm trying to use the API Speech to text in google cloud. I try to give the command under as indicated in the documentation. I've given the value of GOOGLE_APPLICATION_CREDENTIALS as
"D:\certs\My First Project.json" The command is:
requests>curl -s -H "Content-Type: application/json" -H "Authorization: Bearer
"$(gcloud auth application-default print-access-token)
https://speech.googleapis.com/v1/speech:recognize -d #sync-request.json
Which results in:
requests>curl -s -H "Content-Type: application/json" -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) https://speech.googleapis.com/v1/speech:recognize -d #sync-request.json
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Then I tried the command cloud auth by it self:
requests>gcloud auth application-default print-access-token
resulting in:
ERROR: (gcloud.auth.application-default.print-access-token) File "D:\certs\My First Project.json" (pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!
What is the problem with my credentials?
I finally got it, you should not have quotes around the [PATH]/[FILENAME] given for GOOGLE_APPLICATION_CREDENTIALS.
ie
SET GOOGLE_APPLICATION_CREDENTIALS=C:\home\myfile.json
I hope this helps someone.
The error message indicates that your OS is not finding your credential, the official documentation mentioned how to set your environment variable GOOGLE_APPLICATION_CREDENTIALS.
I also suggest to avoid spaces in the path which contains the KEYFILE.json, as is mentioned in the comments. Let me know how it works.

how to use google AI platform online predictions?

i created a custom tensorflow model and deployed to google cloud AI platform
however, when i sent a post request to online prediction api (https://ml.googleapis.com/v1/projects/my-project/models/my-model/versions/my-version:predict). i got back 401 Request is missing required authentication credential. Expected OAuth 2 access token my understand that by deploying model is its API already available online, so is there away to make API public? if not how i can make api authentication through bearer token?
You can get the auth token using gcloud:
access_token=$(gcloud auth application-default print-access-token)
and then embed it into the header:
curl --silent \
-H "Authorization: Bearer $access_token" \
-H "Content-Type: application/json" \
-X POST \
etc.

Openstack authentication always get 401 HTTP response

I am recently doing projects on openstack. I start it. I want to access openstack account through RESTful API. I read the API guide in the official website. The link is here http://developer.openstack.org/api-guide/quick-start/api-quick-start.html#authenticate.
I do the same way to do the authentication.
Here is my command:
curl -s -X POST https://url:5000/v2.0/tokens -H "Content-Type: application/json" -d '{"auth": {"tenantName": "MyTenantName", "passwordCredentials": {"username": "'"myAccountNme"'", "password": "mypassword"}}}'
But everytime I just get 401 (Unauthorized) response said The request you have made requires authentication. The error message is here.
What's wrong with my request? My username and password is correct, I can use it to access my account from dashboard.
Since you are using https, I think you get the error message because you do not specify a certificate. Use the --cert or --cacert option of curl. Something like this:
curl --cacert <your_crt_file> -X POST https://url:5000/v2.0/tokens -H "Content-Type: application/json" -d '{"auth": {"tenantName": "MyTenantName", "passwordCredentials": {"username": "'"myAccountNme"'", "password": "mypassword"}}}'