How to execute curl operation using request module with authorizaion: bearer token? - node.js

I am using Cloud Foundry for Bluemix app creation in that curl operations having Authorization:bearer xxxxx token.
How can I include Authorization: bearer token in request module?

The plain open source Clound Foundry client is able to curl the api like this:
$ cf curl -X GET https://.../v2/...
for instance:
$ cf curl -X GET /v2/apps

Related

why don't my authorization header need Bearer?

I am using curl command to fetch the manifest file of the singularity image as below
curl -H "Authorization :"
and it is working fine for me and i am able to fetch the manifest file andi it is working without appending Bearer
but when I append Bearer string in the Authorization header as below
curl -H "Authorization : Bearer "
curl command is failing to fetch the manifest
but actually it should work when we appended Bearer to Authorization header and it should fail when we dont append Bearer to Authorization header right
why is this happening so and where am i going wrong?

CURL Rest API via Proxy

I want to get data from ServiceNow via a CURL in Putty via a Proxyserver (Plan is to implement it to a PySpark script later on) and then save the data onto the server.
My Command looks like this:
curl -x <proxyadress:port> -U proxyuser:proxypassword -u '<apiuser:apipassword>' -d status="message" "https:/apiadress" -H 'Accept: application/json'
I get the error message:
{"error":{"message":"Invalid content-type. Supported request media types for this service are: [application/json, application/xml, text/xml]","detail":null},"status":"failure"}
A few days ago I was able to have the data printed into the log but didn't manage to replicate the command ... what's wrong?
Thanks for your help

How to upload files to SharepointOnline using curl on Linux

I am trying to automate file uploads to SharePoint Online. Problem is I keep getting 401 unauthorized error when trying to upload the files. I created a script to retrieve the token as suggested in curl request to Microsoft Sharepoint API?, but uploads are still failing, even though I do get a positive response when running curl -i -H "Authorization: Bearer $(./get_access_token.sh)" -H "Accept: application/json;odata=verbose" -s "https://YourTenant.sharepoint.com/_api/web". I have afeeling that I am just malforming my curl command. Any suggestion on command format to be using?

How to change Loopback accessToken from queryString to Bearer Token

I'm working on using Loopback to create a mock service. I need this mock service to authenticate using Bearer Tokens. Something like this:
curl -X GET --header 'Accept: application/json' --header 'Authorization: BEARER ABCDEFG' 'http://localhost:3000/api/Puppies'
At the moment, authentication is handled out of the box using a query string like this:
curl -X GET --header 'Accept: application/json' 'http://localhost:3000/api/Puppies?access_token=ABCDEFG'
Is there a way I can change the default authentication to the former?
In order to authenticate using Bearer tokens, you can use Loopback #loopback/authentication package. If you want to use JWT, you need #loopback/authentication-jwt extension.

How to find Windows Azure Image IDs?

How can I find the publicly available Image IDs on Windows Azure?
I found this related question - Azure: List OS Images
But, the answer requires Windows+PowerShell while I need a way to get it on Linux or REST/
Use the URL specified here:
http://msdn.microsoft.com/en-us/library/windowsazure/jj157191.aspx
You'll need to provide a client certificate when sending the request.
If you are using curl on Linux, add the --cert to point to a .pem file (you'll need to upload it to the administrator's management certificate as a .cer file first).
Don't forget to add the x-ms-version header for it to work:
-H "x-ms-version: 2013-03-01"
Here is an example of using curl to get the auto-scale information for a cloud service
curl -H "accept: application/json" -H "x-ms-version: 2013-10-01"
--cert azure-cert.pem $AUTOSCALEURL

Resources