I want to send the credentials for the #auth.login_required to access my
other methods in my Flask Webapp with a browser.
I know with Curl is:
curl -u username:password -i http://localhost:5000/method
Some example ?
i send like this username:password#localhost:5000/method but didnĀ“t work
On method GET:
http://localhost:5000/method?login='mylogin'&password=123
Typically, browsers will present you with a prompt to enter your credentials. Try simply navigating to the endpoint and see if your browser allows you to enter your credentials.
Related
I am using below python code. But it keep throwing wrong user name or password. Looks like credential are not parsed correctly. But i know credential are correct since it works when i use CURL in DOS command prompt.
import requests as re
import json
re.packages.urllib3.disable_warnings()
url = 'https://nwsppl300p:9090/nwrestapi/v3/global/clients/?q=hostname:BMCJCA001T.corpads.local'
auth = ('cormama.remote\jamal', 'Inventigation100get$pump')
r = re.get(url, auth=auth,verify=False)
print (r.content)
Getting message
b'{"message":"Unauthorized access: The username or password is incorrect","status":{"code":401,"codeClass":"Client Error","reasonPhrase":"Unauthorized"},"timestamp":"2022-06-17T15:00:14-04:00","userAgentRequest":{"headers":[{"name":"Accept","value":"*/*"},{"name":"Accept-Language"},{"name":"Content-Type"}],"method":"GET","query":"q=hostname:BMCJCA001T.corpads.local","url":"https://nwsppl300p:9090/nwrestapi/v3/global/clients/"},"version":"19.5.0.5.Build.154"}'
It seems to me that you are either providing the wrong creds, or perhaps in the wrong format.
Are you able to access your site in a browser using those credentials?
Do you know how to use Fiddler Classic?
You can use Fiddler to capture the call (turn ON HTTPS encryption) when using the browser and capture that call to understand the format needed. note: if you leave fiddler running when debugging; it is a proxy and may interfere with VScode if you are using that to debug...you can use the following to get proxy certs:
os.environ['CURL_CA_BUNDLE'] = ''
The example below requires that I POST a json with my creds in order get my auth token. Your site may be different, but you can use this to figure out what it needs specifically.
in the example shown:
userName = {"email":"someEmail", "password":"somepass"}
auth = re.post(url, json=userName)
Need to create an email with the different mail components like send_from, send_to, attachments and html_body using python and flask. I need the exact curl command to do the same. Tried the following curl which gives errors:
curl -F 'files=#/tmp/holiday.png' -F 'files=#/home/user1/sample.html' -F metadata="{'send_from':'xyz#domain.com'}" http://localhost:8085/mail
I believe this is a form data POST request method. Is there something wrong in this curl? How do I parse the content of the file to create html body?
I'm trying to call Github APIs to the Github Enterprise Server in the company that I work for. The API calls works when I use personal access token, but every time I used user name and password, I'm getting an HTTP 401 error message "Must authenticate to use this API".
I tried using the following tools:
curl
Sample call:
curl --proxy $PROXY -i --user "xx-xx" https://github.xxx.xxx.com/api/v3/users
PyGithub
Sample code:
gh = Github('my-user', password='....', base_url='https://github.xxx.xxx.com/api/v3/users')
Python requests API
Sample code
r = requests.get('https://github.xxx.xxx.com', auth=('my-user','....'), proxies=proxyDict)
Doesn't work if I use either HTTPBasicAuth or HTTPDigestAuth
The company github website is authenticated via SAML, so I'm wondering if this is SAML related issue.
Github does not allow http/https authentications. (same for bitbucket and gitlab). I learnt it hard-way.
You may want to use ssh public key based authentication.
Github API supports Basic Authentication as defined in RFC2617 with a few small differences.
cURL example:
curl -u username https://api.github.com/user
cURL will prompt you to enter the password.
PyGitHub example:
g = Github("user", "password")
for repo in g.get_user().get_repos():
print(repo.name)
Requests example:
response = requests.get('https://api.github.com/user', auth=('username', 'password'))
I would suggest using PyGitHub instead of Requests. And also Postman which is a nice cURL alternative to try things out.
I would like to use the python instagram api but am struggling over the correct setting for the redirect url.
I have been able to feed the authorize url in by hand into a browser and get a
token back in the return url. I that case; I set the URI to localhost (127.0.0.1)
Whenever I do this via the api I end up with 400 returns.
What I would really appreciate is
1) a working example
2) when running via a script; what should be listening for the server's response that contains the token in its url ?
Thanks for any and all help
Working with the Streak CRM API by using Python and Request. I am getting 4XX errors depending on how I phrase the request. (Examples below)
response = requests.get('https://www.streak.com/api/v1/pipelines?api-key=xxxxxxxx')
response.headers['Content-Type'] = 'application/json'
print(response.status_code)
print(response.content)
Result: 401 "Authentication Required for Streak API: try HTTP Basic Auth or cookie auth"
If I add ".json" after the file path:
requests.get('https://www.streak.com/api/v1/pipelines.json?api-key=xxxxxxxx')
Result: 400 "Invalid API path specified" So I am assuming that I was authenticated but just have a poorly defined file path.
But if I use the same file path and credentials entered in the terminal:
curl https://www.streak.com/api/v1/pipeline -u xxxxxxxx:
Works like a charm.
Why would the file path work in the terminal but not in python? Why do I need to add .json to my file path? New to using APIs so any help is appreciated. Thanks.
I don't know why, but rephrasing it like below worked. I received status code 200:
response = requests.get('https://www.streak.com/api/v1/pipelines', auth=('xxxxxx',''))
The API key goes in the username parameter, and the password parameter is left blank.
The error message tells you all you need to know. For Basic Auth you put the authorization info in the request headers, not in the url. When you add .json to a endpoint, that usually means that you want a JSON response. The reason why it worked with curl is because curl's -u flag is setting the Auth header.