Dialogflow API bearer token - google-oauth

How to I get a bearer dev-token for a Dialogflow v2 api call? I would like to run this command from my command-line interface on Mac osx. An example request is below:
curl -X GET "https://dialogflow.googleapis.com/v2/projects//agent/intents/?intentView=INTENT_VIEW_FULL" -H "Authorization: Bearer "

There is a request example.
curl -X POST -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
"https://dialogflow.googleapis.com/v2/projects/{your-project-id}/agent/sessions/{session-id}>:detectIntent:detectIntent" \
--data "{'queryInput':{'event':{'name':'MY_CUSTOM_EVENT','parameters':{'parameter-name-1': 'parameter-value-1','parameter-name-2':'parameter-value-2',},'languageCode':'en-US'}}}"
For more requests to make, refer to API reference
According to Setting up authentication, if you want to use v2 API call, you have to
Create the Service Account key.
Download the JSON key file.
Install and initialize the Cloud SDK.
Add an environment variable GOOGLE_APPLICATION_CREDENTIALS (which the value is the path point to the JSON key file) to your shell.
You can test whether the Cloud SDK and variable is set up correctly by executing echo $(gcloud auth application-default print-access-token) in your console.
Then you should be able to make the request.
After making your request, you can navigate to the History tab in the Dialogflow console to check whether the request was successfully sent.

Related

Using Metabase API behind google oauth

I have a Metabase Docker image running locally that is routed to the URL:
https://metabase.example.com
I am trying to. do a curl on this to grab a Metabase token to use the Metabase API; however, this URL is hidden behind Google oauth, so I believe I need to first get a google oauth token for the test#company.com service account I am using which I can then pass to the curl request below.
curl --location --request POST 'https://metabase.example.com/api/session/google_auth' \
--header 'Content-Type: application/json' \
--data-raw '{"username": "test#company.com", "password": "password123"}'
Is there a simple way I can grab this Google Oauth token via CURL to then use in the above curl statement for metabase?

THINGSBOARD REST API CALL Node

Please be kind and tell me how to execute the following CURL command with REST API Call node from Thingsboard 2.5.2:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"username":"tenant#thingsboard.org", "password":"mypassword"}' 'http://127.0.0.1:8080/api/auth/login'
How can I send the -d '{"username":"tenant#thingsboard.org", "password":"mypassword"}' to the REST API CALL node ?
Thank You !
As described on the documentation page, the first step is indeed to POST on /api/auth/login providing a username and password in order to retrieve a JWT token. This is the first step you described in your curl call.
Then, for further calls to other API endpoints, you must send a X-Authorization HTTP header with the Bearer: $TOKEN as a value.
Note that if you want to interact with the Thingsboard administration API with Java or Python, clients are available to abstract this.

user authentication in wso2 via curl

I need to authenticate admin user via curl command so I can pragmatically add,delete, modify users in wso2
I can call the api end points for user add/mod/delete no problem. But without being able to first authenticate to wso2 it is all for naught. When I send the curl command I get no response back, and nothing shows in the logs.
This is my basic curl command, right out of the books:
curl -X POST "https://xxxxxxx.com:9443/login/portal" -H "Content-Type: application/x-form-urlencoded" -d "username=uid&password=foo&grantType=password"
You can use SCIM APIs with basic authentication to manage users.
If you want to use OAuth2 tokens, you can get them like this.
curl -k -d "grant_type=password&username=<username>&password=<password>"
-u <Consumer_key>:<Consumer_secret>
-H "Content-Type: application/x-www-form-urlencoded"
https://localhost:9443/oauth2/token
[1] https://docs.wso2.com/display/IS530/SCIM+1.1+APIs

How can I obtain a Mule ARM registration token to be used to register a server into AMC

I was reading at
https://anypoint.mulesoft.com/apiplatform/anypoint-platform/#/portals/organizations/ae639f94-da46-42bc-9d51-180ec25cf994/apis/38784/versions/127446/pages/182856
because I want to automate Anypoint Runtime Manager enablement on lots of servers.
My plan is to use REST to get the proper registration token to be used to register a server into AMC. There are directions on the page:
To register a server you must first authenticate against the Anypoint Platform Authentication Manager and get an authentication token, with this token you need to obtain a registration token to be used to register a server into AMC.
I understand the first part and can get the authentication token, but I can't find a reference to how to get the registration token.
How can I get this token?
Thanks!
have you seen the Obtain the Server Registration Token part in the documentation?
take a look here, if you want to obtain a registration token by calling the REST API. There is a API endpoint called /servers/registrationToken
You can also get a registration token with the new anypoint-cli v2.x. This will combine several REST API calls for you. The command is:
runtime-mgr server token
You can type this in the interactive shell, or add this to the end of a stand-alone call from your favorite scripting environment. For example, if you have created a profile with your ANYPOINT_USERNAME, ANYPOINT_PASSWORD, and ANYPOINT_ORG, and ANYPOINT_ENV, you can then call:
anypoint-cli runtime-mgr server token
You can find the docs and installation instructions here: docs.mulesoft.com/runtime-manager/anypoint-platform-cli#runtime-mgr-server-token.
If you want to do this directly with the REST API, you'll have to make several calls:
POST a core services access_token from
anypoint.mulesoft.com/accounts/login
with the username and password in the BODY as a JSON object.
curl -X POST \
anypoint.mulesoft.com/accounts/login \
-H 'content-type: application/json' \
-d '{
"username":"yourUserName",
"password":"yourPassword"
}'
Store the response as a variable (let's call it {{access_token}}.
Copy this access_token in the header for every other API call: Key: Authorization, Value: bearer {{access_token}}
Obtain or store the organization ID in which you want to register the server. There's several ways to do this. The value is available via a GET request to
anypoint.mulesoft.com/accounts/api/me
curl -X GET \
anypoint.mulesoft.com/accounts/api/me \
-H 'authorization: bearer aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
You might want to use the JQ libraries to parse the organizationID from this JSON response.
Get the environment ID for the environment in which you want to register the Mule runtime (server) from a GET request to:
anypoint.mulesoft.com/accounts/api/organizations/{{organizationId}}/environments
curl -X GET \
https://anypoint.mulesoft.com/accounts/api/organizations/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb/environments \
-H 'authorization: bearer aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' \
-H 'content-type: application/json'
Make a GET request to
anypoint.mulesoft.com/hybrid/api/v1/servers/registrationToken
With the headers X-ANYPNT-ORG-ID and X-ANYPNT-ENV-ID set:
curl -X GET \
anypoint.mulesoft.com/hybrid/api/v1/servers/registrationToken \
-H 'authorization: bearer aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' \
-H 'x-anypnt-env-id: cccccccc-cccc-cccc-cccc-cccccccccccc' \
-H 'x-anypnt-org-id: bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'
This will return a registration token.
Then use this registration token with the amc_setup -H command
amc_setup -H {{registration_token}} Server-Name

How to create a task in Salesforce using curl?

Which URL I should send the request to? (I already have my instance, I need the path). I have the oauth token, and I have the data.
Thanks!
H
OK I've got it:
curl -H 'Authorization: Bearer <oauth token>' \
https://<your instance url>/services/data/v20.0/sobjects/Task