Adding private key to Google audio to text API - google-cloud-speech

I have submitted a request for google Audio to text. I received the name back, but I am unsure how to add private key info from file downloaded to:
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/your-operation-name"
and then am I able to run the command from web or Mac?

You can set up the environment variable to use the private key as mentioned here. Though the link talks about Vision API, the process is similar to use Cloud Speech-to-Text API. Also, here is additional documentation for authentication. This can be run from the web.

Related

how to make curl requests to app protected by AzureAD oauth2

I have an app which is protected by azureAD app registration. everytime user hits an URL, say, https://myapp.com/listall in browser they are presented with azure login screen. This is working as expected.
I was wondering how can I make curl requests to these endpoints from my terminal. When I try it now I get 302 NOT FOUND, as my request is getting redirected to login screen. when I try this form postman I see browser(HTML, CSS) code for azures login screen.
I am expecting something like.
make a curl request to obtain a token.
Use this token to subsequent curl requests.
I am making this curl request to get a token
-H "Content-Type: application/x-www-form-urlencoded" \
--data \
"
grant_type=client_credentials&
client_id=<client-id>&
client_secret=<client-secret>&
resource=https%3A%2F%2Fmanagement.core.windows.net%2F
"
I get a token back and then I make request something like this.
curl -X GET "https://myapp.com/listall" -H 'Content-Type: application/json' -H "Authorization: Bearer eyJ0eXAiOiJKV1....."
am I on the right path? how can I achieve this so that I can make curl requests to apps protected by azure AD app registration ?
I tried to reproduce the same in my environment and got the access token successfully.
Please note that the resource URL you are using is for classic deployed resources and https://management.core.windows.net/ corresponds to Azure Service Management API which is now changed to https://management.azure.com/
To get the access token, I made CURL request like below:
curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' \
https://login.microsoftonline.com/your_tenant_id/oauth2/token\
-d 'client_id=your_app_client_id' \
-d 'grant_type=client_credentials' \
-d 'resource=https://management.azure.com/' \
-d 'client_secret=*******************'
To call the above CURL request in Postman, please follow below steps:
Run Postman -> Import -> Select Raw Text -> Copy the above CURL request and paste in raw text field -> Continue -> Import -> Send.
Response:
After getting the token, I made API call like below:
curl -X GET "Your_API_Call_http_link" -H 'Content-Type: application/json' -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS....."
Make sure to grant API permissions for your API before calling it in Postman. Ensure to select access tokens and id tokens check boxes for your Azure AD app.

How to obtain temporary authorization code in Slack API?

I am referring https://api.slack.com/docs/oauth#flow to obtain access token in PostMan.
Also, I have downloaded repo of slack api from https://github.com/lonelyclaud/slack-api-postman
Below command returns status 200, but no authorization code.
curl -X GET \
'https://slack.com/oauth/authorize?client_id=9XX331444993.996747590037&scope=team%3Aread+users%3Aread%20' \
-H 'Postman-Token: f2dc4c20-5b7d-4ed2-b71f-08ecad81fd8c' \
-H 'cache-control: no-cache'
Can someone explain how to obtain code, which in turn will be used to obtain token?
Got my answer, here is the link to obtain the auth token using Postman Create a Slack app and authenticate with Postman

google api machine learning can I use an API KEY?

For learning purposes, I'm trying to use the Machine learning (ml) API.
https://cloud.google.com/ml-engine/reference/rest/v1/projects.models/list
I'm not able to identify if this request can be done with an API KEY instead of OAUTH.
I'm using npm package googleapis with this;
ml.projects.models.list({
key: GCLOUD_API,
parent: "projects/"+GCLOUD_PROJECT
}
But always receives this error:
Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential
I've tried replacing key with auth or token. Nothing work.
How can I know if is possible or not to use an api key?
I tried also with curl
'https://ml.googleapis.com/v1/projects/myproject-123456/models?token=my_super_sekret_key'
Today I had the same doubt.
Here are GCP Services that support API Keys:
https://cloud.google.com/docs/authentication/api-keys and ML API is not included.
You should obtain the access token using OAuth2, so URL POST request will be:
https://ml.googleapis.com/v1/projects/your_project/models?access_token=your_access_token
Works great for me. Same to do predictions.
1
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 \
-d "$request" \
https://ml.googleapis.com/v1/projects/myproject-123456/models

How do I upload a file using the Box API using app credentials?

I want the user to upload to our server and have our server then upload the file to a specific folder in Box using the API. How can I do this? What credentials should I use?
curl https://app.box.com/api/oauth2/token \
-d 'grant_type=client_credentials&client_id=CLIENT_ID&client_secret=SECRET'
returns
{"access_token":"TOKEN","expires_in":3793,"restricted_to":[],"token_type":"bearer"}
curl https://upload.box.com/api/2.0/files/content \
-H "Authorization: Bearer TOKEN" -X POST -F \
file=#package.json -F folder_id=3306197480
returns
{"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"parent","message":"Invalid value 'd_3306197480'. 'parent' with value 'd_3306197480' not found"}]},"help_url":"http://developers.box.com/docs/#errors","message":"Not Found","request_id":"1157604954550c7c754b9c9"}
It sounds like the API is returning a 404 because the user associated with the access token doesn't have permissions to see the folder you're uploading to. Your server will need to authenticate as a user that is collaborated on that folder instead of authenticating as the user uploading the file.

How do I obtain an OAuth token from WSO2 using the Consumer Key/Secret?

I am very new to WSO2 and am still evaluating it - mostly through Fiddler. It is my understanding that I should be able to obtain an OAuth token by calling WSO2's Login API. I have attempted various URLs (in Fiddler) along the lines of:
// Based off a blog post : http://lalajisureshika.blogspot.com/2012/11/generate-application-tokens-user-tokens.html
http://localhost:8280/login?grant_type=password&username=admin&password=admin&scope=PRODUCTION
Authorization: Basic cFNET0lab1RnMHRBODRCWmQ4bTRBbnp1c0RZYTpZREIzZzh3RXhQOV92ZTdZX1drYVhieWx5ZlVh
When I execute the above URL, I receive (403) No matching resource found in the API for the given request.
I can use the the "Access Token" (via the Bearer tag) and the APIs work. I just can't figure out how to obtain the OAuth token for actual runtime use.
Any pointers/ideas?
--- Thanks, Jeff
Setup Identity Server [domain:9443]
Create OAuth2 application, and get client id + consumer key
Get Base64 encoded of clientId:consumerKey - replace this for Authorization Basic xxxxx
Replace the REST endpoint for token generation - This you should get in oauth application on management console [in our case https://domain:9443/oauth2/token]
And below curl command should give you the response
curl -k -d "grant_type=password&username=sasikumar#domain.com&password=xxxx1234" -H "Authorization" -H "Authorization: Basic X2dhWllidkN6TDNQY2ZqSmVBQ1lsNlg2SFdRYTpSQVlSMmxOZzQ0enU5ZXVGSDRDVXdOUWRudlVh, Content-type=application/x-www-form-urlencoded" https://domain:9443/oauth2/token
You can directly access OAuth2 REST web service to access the token.Here is how you can access token using curl
curl --user ConsumerKey:ConsumerSecret -k -d "grant_type=password&username=admin&password=admin" -H "Content-Type:application/x-www-form-urlencoded" https://localhost:9443/oauth2endpoints/token
Below is an example using cURL tool available in linux by default ( you can install cURL for windows explictly)
curl -v 4 -X POST -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -k -d "grant_type=password&username=&password=&client_id=&client_secret=" https://:9443/oauth2/token
to obtain the client_secret & client_id you have to register a app in wso2is.
There are free tools available to construct the above request or directly use the above parameters and to get the token.
Setup Identity Server [domain:9443]
Create OAuth2 application, and get client id , consumer key and url.
Process post request by using 'poster' with bellow details ,
URL :- which get from oauth application
Content Type :- application/x-www-form-urlencoded
body:- grant_type=password&username=your username&password=your password&client_id=your client id&client_secret=your client secret

Resources