wget - 401 Unauthorized, but URL is working fine - wget

Below is the command I'm trying.
wget -o /tmp/response.txt <url> --ca-certificate=< my-ca-cert> --certificate=< my-cert> --private-key=< my-private-key> --no-check-certificate
Result:
HTTP request sent, awaiting response... 401 Unauthorized
Authorization failed.
Note: I've checked for the ceritificates, private keys, etc and those are good. Also, when I'm trying to hit the URL directly from browser, it is working fine.
Please suggest.

After almost an year, I got the solution for my issue.
Since the URL was working in a browser, I went ahead and inspected through WireShark and found out that, this URL was internally connecting to a SiteMinder
for Authentication.
I had to allow the linux box (used for wget command) in the SiteMinder and it worked like a charm!

Related

download gitub artifact from url using wget

I am trying to follow these docs to download an artifact from github using githubs API:
https://docs.github.com/en/rest/actions/artifacts#download-an-artifact
I ran the curl command given in the docs, and it gave me the following url from which to download the artifact (I have replaced the specifics with ...)
https://pipelines.actions.githubusercontent.com/serviceHosts/..../_apis/pipelines/1/runs/16/signedartifactscontent?artifactName=my-artifact&urlExpires=....&urlSigningMethod=HMACV2&urlSignature=....
I am able to download the artifact by putting the URL into my browser (it automatically downloads when the URL is visited) however I tried to use wget to download it via console and got this error:
wget https://pipelines.actions.githubusercontent.com/... # the command I ran
HTTP request sent, awaiting response... 400 Bad Request # the error I got
How can I download a zip file to console? Should I use something other than wget?
I'd like to clarify that viewing this link in the browser is possible even when not logged in to github (or when in private browsing). Also, I can download the zip file at the link as many times as I would like before the link expires after 1 minute. Also my repo is private, which is necessary for my work. I need to use an access token when doing the curl command as described in the docs, however the link that is returned to me does not require any authentication when accessed via a browser.
The api docs seem a bit ambiguous here. It is possible that the redirect can only be accessed a single time in which case you should try generating the redirect and first using wget to parse it. You can then unzip the file using the unzip command.
If that is not the case I believe this statement in the api docs is key:
Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.
My guess is that your repository is private and you are logged in on the browser to Github which allows you to be authenticated hence why you are able to download from the redirect link. I would suggest trying from incognito mode to test this.
Migrating the repository to public would allow you to bypass this issue. Alternatively you can pass the authentication token as a header to wget like so in order to authenticate with the server to pull the file.
header='--header=Authorization: token <TOKEN>'
wget "$header" https://pipelines.actions.githubusercontent.com/... -O output_file
The problem was that I didn't put quotes around my url. I needed to do this:
wget "https://pipelines.actions.githubusercontent.com/serviceHosts/..../_apis/pipelines/1/runs/16/signedartifactscontent?artifactName=my-artifact&urlExpires=....&urlSigningMethod=HMACV2&urlSignature=...."

Gerrit Code Review - How to download a file with wget using http password?

I'd like to donwload a single file from a gerrit server which a no read access for anonymous users.
Therefore I set the http password for the user and tried something like:
wget --user=user --password=passwd "http://example.com:8443/gitweb/?p=...;a=blob_plain;f=...;hb=refs/heads/master"
HTTP request sent, awaiting response... 401 Unauthorized
Unknown authentication scheme.
Is this possible at all using the http password generated in the user settings of gerrit?
Thank you!
Yes, it possible to use the HTTP password generated in the user setting. Have a look at the Authentication documentation here.
However, Gerrit Code Review doesn't allow you to download a single file (unless you have a particular plugin installed to do so). Are you sure downloading a single file is what you want?
the following works for me:
http://your gerrit:8080/gitweb?p=your repository.git;a=blob_plain;f=path/to/file -O file

unable to call REST API from browser

My REST API with basic authentication works fine using Rest client (Google Chrome extn).
The same also working fine with below Curl command:
curl --header "Accept:application/json" -i --user user1:user1Pass http://localhost:8080/authenticate
But when testing the same in browser I'm getting 404 not found error. The browser URL: http://user1.user1Pass#localhost:8080/authenticate
Can anyone please help me on this?
You're using a period instead of a colon.
The format of the url should be http://user1: user1Pass#localhost:8080/authenticate
The main point is you need to separate username and password by colon.

Github API returns 404, but default http request returns 301

I try to get Github repository info.
At first some test. I have next url:
https://github.com/airbnb/rendr
When I paste it to my browser, it redirects me to
https://github.com/rendrjs/rendr
If I try first link via curl, it returns status 301 with Location: https://github.com/rendrjs/rendr
I try to get repository info using Github API. For this we should call something like this:
https://api.github.com/repos/:owner/:repo
But when I try curl -i "https://api.github.com/repos/airbnb/rendr" I get 404 error; for curl -i "https://api.github.com/repos/rendrjs/rendr" I get the info and status 200. If I add Accept: application/vnd.github.v3+json header (for using API v3, default is beta) I have the same result.
So, can I somehow get repository info using Github API and the first link? I expected at least 301 like a default http request.

Facebook Real-time Updates: (#2200) callback verification failed, code 2200

I am trying to get realtime updates from facebook for my application as documented in https://developers.facebook.com/docs/reference/api/realtime/. I am struggling now when it comes back to the Subscription Verification. I have set up a callback server which accepts both GET and POST requests. I verified that the server works by making curl requests to it.
However, I stil get this error when attempting to create a subscription issuing the POSt request below
{"error":{"message":"(#2200) callback verification failed:
","type":"OAuthException","code":2200}
From what I read in the documentation and other threads, I assume that this means that the single GET request to my callback URL fails. The callback url does not get requested by neither GET nor POST requests indeed. I suppose that facebook is somehow blocked from accessing the endpoint. However, I am able to auth as a user using the auth dialog (https://developers.facebook.com/docs/reference/dialogs/oauth/) where I pass a callback url on the same server as well. The server runs http (for now).
This is the curl I am using to post the subscription. Host file has an entry to redirect dev.minggler.com to localhost =>( 127.0.0.1 dev.minggler.com)
curl -XPOST 'https://graph.facebook.com/256139341164822/subscriptions?callback_url=http%3A%2F%2Fdev.minggler.com%3A3000%2Ffacebook%2Frealtimeupdates&object=user&fields=friends&verify_token=abcd123&access_token=$MYTOKEN'
Can anybody help me out on this?
finally found the problem. the server wasn't reachable from outside. resolving it solved the problem