Saravanan666/pypi-org huggingface dataset:
Package: requests-mauth
requests-mauthrequests-mauth is a python requests (http://docs.python-requests.org/en/latest/) Authentication implementation
for Medidata'sMAuthauthentication system.PrerequisitesTo use MAuth authentication you will need:An MAuth APP IDAn MAuth private key (with the public key registered with Medidata's MAuth server)Usingimportrequestsfromrequests_mauthimportMAuth# MAuth configurationAPP_UUID="<MAUTH_APP_UUID>"private_key=open("private.key","r").read()mauth=MAuth(APP_UUID,private_key)# Call an MAuth protected resource, in this case an iMedidata API# listing the studies for a particular useruser_uuid="10ac3b0e-9fe2-11df-a531-12313900d531"url="https://innovate.imedidata.com/api/v2/users/%s/studies.json"%user_uuid# Make the requests call, passing the auth clientresult=requests.get(url,auth=mauth)# Print resultsifresult.status_code==200:print([r["uuid"]forrinresult.json()["studies"]])print(result.text)DevelopmentWe usetravisfor automated CI of the code (and status checks are required to pass prior to PR merges being accepted).
We use travis to deploy updated versions to PyPI (only frommaster)For local development (cross version) we usetoxwithpyenvto automate the running of unit tests against different python versions in virtualised python environments.To setup your environment:Install PythonInstall Pyenv$brewupdate
$brewinstallpyenvInstall Pyenv versions for the Tox Suite$pyenvinstall2.7.163.3.63.4.63.5.33.6.13.7.2Install Tox$pipinstalltoxtox-pyenvSetup the local project versions (one for each env in theenvlist)$pyenvlocal2.7.163.3.63.4.63.5.33.6.13.7.2Make any changes, update the tests and then run tests withtoxNameStmtsMissCover------------------------------------------------requests_mauth/__init__.py30100%requests_mauth/client.py310100%requests_mauth/rsa_sign.py340100%------------------------------------------------TOTAL680100%statsruntests:commands[1]|coveragehtml_________________________________________________________________________________________________________summary__________________________________________________________________________________________________________clean:commandssucceededpy27:commandssucceededpy33:commandssucceededpy34:commandssucceededpy35:commandssucceededpy36:commandssucceededstats:commandssucceededcongratulations:)Coverage report can be viewed usingopen htmlcov/index.htmlPush your changes and create a PR tomasterOnce the PR is complete, tag the branch and push it to github, this will trigger Travis to deploy to PyPI (make sure the version is consistent)$gitcheckoutmaster
$gitpull
$gittag-a1.0.2-m"Requests MAuth 1.0.2"$gitpush--tags
Package: requests-middleware
TL;DR:requests-middlewareis a custom transport adapter that allows simple
composition of HTTP interactions.Thepython-requestslibrary makes excellent use of transport adapters to
allow for easy extension and modification of HTTP interactions. There are
adapters for SSL configuration, rate-limiting, and testing, and writing your
own adapters is easy.But what if you want to use more than one of those behaviors for the same
session? What if you want HTTP cachingandrate-limiting? Requests only
uses one adapter per URL. You could write a newCachingRateLimitingHTTPAdapter, but that’s probably not the best solution.requests-middlewareis an effort to preserve the modularity of adapters,
while allowing simple composition of multiple types of interaction. Want to
use HTTP caching, respect robots.txt files, and limit your application to
10 requests per hour? No problem!importrequestsfromrequests_middlewareimportMiddlewareHTTPAdapterfromrequests_middleware.contrib.cachewareimportCacheMiddlewarefromrequests_middleware.contrib.robotwareimportRobotsMiddlewarefromrequests_middleware.contrib.throttlewareimport\ThrottleMiddleware,RequestsPerHourThrottlersession=requests.Session()middlewares=[CacheMiddleware(),RobotsMiddleware(),ThrottleMiddleware(RequestsPerHourMiddleware(10)),]adapter=MiddlewareHTTPAdapter(middlewares)session.mount('http://',adapter)session.mount('https://',adapter)
Package: requests-middleware-ali-hmac
requests_middleware_ali_hmacrequests_middleware_ali_hmac demoimportrequestsfromrequests_middlewareimportMiddlewareHTTPAdapterfromrequests_middleware_ali_hmacimportAliHmacGeneratesession=requests.Session()middlewares=[AliHmacGenerate("testid","testsecret"),]adapter=MiddlewareHTTPAdapter(middlewares)session.mount('http://',adapter)session.mount('https://',adapter)allow requests methods "GET", "POST", "PUT", "DELETE", "PATCH"
Package: requests-mock
Introrequests-mockprovides a building block to stub out the HTTPrequestsportions of your testing code.
You should checkout thedocsfor more information.The BasicsEverything inrequestseventually goes through an adapter to do the transport work.requests-mockcreates a customadapterthat allows you to predefine responses when certain URIs are called.There are then a number of methods provided to get the adapter used.A simple example:>>>importrequests>>>importrequests_mock>>>session=requests.Session()>>>adapter=requests_mock.Adapter()>>>session.mount('mock://',adapter)>>>adapter.register_uri('GET','mock://test.com',text='data')>>>resp=session.get('mock://test.com')>>>resp.status_code,resp.text(200,'data')Obviously having all URLs bemock://prefixed isn’t going to be useful,
so you can userequests_mock.Mockerto get the adapter into place.As a context manager:>>>withrequests_mock.Mocker()asm:...m.get('http://test.com',text='data')...requests.get('http://test.com').text...'data'Or as a decorator:>>>@requests_mock.Mocker()...deftest_func(m):...m.get('http://test.com',text='data')...returnrequests.get('http://test.com').text...>>>test_func()'data'Or as a pytest fixture:>>>deftest_simple(requests_mock):...requests_mock.get('http://test.com',text='data')...assert'data'==requests.get('http://test.com').textFor more information checkout thedocs.Reporting BugsDevelopment and bug tracking is performed onGitHub.QuestionsThere is a tag dedicated torequests-mockonStackOverflowwhere you can ask usage questions.LicenseLicensed under the Apache License, Version 2.0 (the “License”); you may
not use this file except in compliance with the License. You may obtain
a copy of the License athttps://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
Package: requests-mock-df
NOTE: This Package fork byrequests-mock==1.8.0and fixed some bug.
if requests-mock release the new version, you should reinstall itpip installrequests-mock-UIntrorequests-mockprovides a building block to stub out the HTTPrequestsportions of your testing code.
You should checkout thedocsfor more information.The BasicsEverything inrequestseventually goes through an adapter to do the transport work.requests-mockcreates a customadapterthat allows you to predefine responses when certain URIs are called.There are then a number of methods provided to get the adapter used.A simple example:>>>importrequests>>>importrequests_mock>>>session=requests.Session()>>>adapter=requests_mock.Adapter()>>>session.mount('mock://',adapter)>>>adapter.register_uri('GET','mock://test.com',text='data')>>>resp=session.get('mock://test.com')>>>resp.status_code,resp.text(200,'data')Obviously having all URLs bemock://prefixed isn’t going to be useful,
so you can userequests_mock.Mockerto get the adapter into place.As a context manager:>>>withrequests_mock.Mocker()asm:...m.get('http://test.com',text='data')...requests.get('http://test.com').text...'data'Or as a decorator:>>>@requests_mock.Mocker()...deftest_func(m):...m.get('http://test.com',text='data')...returnrequests.get('http://test.com').text...>>>test_func()'data'Or as a pytest fixture:>>>deftest_simple(requests_mock):...requests_mock.get('http://test.com',text='data')...assert'data'==requests.get('http://test.com').textFor more information checkout thedocs.Reporting BugsDevelopment and bug tracking is performed onGitHub.QuestionsThere is a tag dedicated torequests-mockonStackOverflowwhere you can ask usage questions.LicenseLicensed under the Apache License, Version 2.0 (the “License”); you may
not use this file except in compliance with the License. You may obtain
a copy of the License athttps://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
Package: requests-mock-flask
requests-mock-flaskrequests-mock-flaskhelps with testingFlaskapplications withhttpretty,responsesorrequests-mock.InstallationUsage exampleUse casesFull documentationInstallationRequires Python 3.11+.pipinstallrequests-mock-flaskUsage exampleimportflaskimportrequestsimportresponsesimportrequests_mockfromrequests_mock_flaskimportadd_flask_app_to_mockapp=flask.Flask("test_app")@app.route('/')def_()->str:return'Hello, World!'@responses.activatedeftest_responses_decorator()->None:"""
    It is possible to use the helper with a ``responses`` decorator.
    """add_flask_app_to_mock(mock_obj=responses,flask_app=app,base_url='http://www.example.com',)response=requests.get('http://www.example.com')assertresponse.status_code==200assertresponse.text=='Hello, World!'deftest_responses_context_manager()->None:"""
    It is possible to use the helper with a ``responses`` context manager.
    """withresponses.RequestsMock(assert_all_requests_are_fired=False,)asresp_m:add_flask_app_to_mock(mock_obj=resp_m,flask_app=app,base_url='http://www.example.com',)response=requests.get('http://www.example.com')assertresponse.status_code==200assertresponse.text=='Hello, World!'deftest_requests_mock_context_manager()->None:"""
    It is possible to use the helper with a ``requests_mock`` context
    manager.
    """withrequests_mock.Mocker()asresp_m:add_flask_app_to_mock(mock_obj=resp_m,flask_app=app,base_url='http://www.example.com',)response=requests.get('http://www.example.com')assertresponse.status_code==200assertresponse.text=='Hello, World!'deftest_requests_mock_adapter()->None:"""
    It is possible to use the helper with a ``requests_mock`` fixture.
    """session=requests.Session()adapter=requests_mock.Adapter()session.mount('mock',adapter)add_flask_app_to_mock(mock_obj=adapter,flask_app=app,base_url='mock://www.example.com',)response=session.get('mock://www.example.com')assertresponse.status_code==200assertresponse.text=='Hello, World!'Use casesUserequestsor other Python APIs for testing Flask applications.Create a test suite which can test a Flask application as well as a live web application, to make a verified fake.Test a service which calls a Flask application that you have the source code for.Full documentationSee thefull documentationfor more information including how to contribute.
Package: requests-ms-auth
Python Requests for OAuth2 with ADAL / MSAL with auto-renew access tokenAboutThis project provides a simpleRequestscompatible session that you can use to authenticate with Microsoft using he following:Azure Active Directory Authentication Library (ADAL)Microsoft Authentication Library (MSAL). (not finished, use ADAL instead)Sessionrenews access token automatically(by default token expires each hour).The package is available onPyPi.How to useInstall the packagepython3-mpipinstall--upgraderequests_ms_authUse an exampleNOTE: These examples are made for easy access to Equinor specific systems.NOTE: Before using the example you should first fill the credentials inside the example file.DescriptionExample codePython code to accessMetadata APIusing session directlymetadata_api_example.pyThe session should automatically fetch a token on startup and renew it when the token expires.
Session will also verify itself in the constructor using the optionalverification_urlif specified, allowing you to terminate early on failure.ConfigurationSession configuration details might be found in the docstringhereImplementation detailsThe library usespip-compilewithrequirements.into manage and pin requirements. Requirements for test are maintained in a separatetest_rquirements.in.The library uses a Makefile to manage building, packaging and uploading of versions, as well as many short-cuts for running tests, compiling requirements and more.The library is built and tested by github actions.The package is prepared and uploaded to PyPi by github actions.The library defaults toADALand can be told to useMSALas an option.To supply OAuth2 compatability the library depends onRequestsRequests-OAuthlibTestsConfig env variablesExport following ENV variables (with previously replaced values):from shell:exportINTEGRATION_TENANT=tenantexportINTEGRATION_CLIENT_ID=idexportINTEGRATION_CLIENT_SECRET=secretexportINTEGRATION_RESOURCE=resourseexportINTEGRATION_AUTHORITY_HOST_URL=authorityexportINTEGRATION_LIVE_VERIFICATION_URL=verificationexportINTEGRATION_LIVE_VERIFICATION_ELEMENT=elementOR add env variables to Pycharm or other IDE (with previously added values):INTEGRATION_TENANT=tenant;INTEGRATION_CLIENT_ID=id;INTEGRATION_CLIENT_SECRET=secret;INTEGRATION_RESOURCE=resourse;INTEGRATION_AUTHORITY_HOST_URL=authority;INTEGRATION_LIVE_VERIFICATION_URL=verification;INTEGRATION_LIVE_VERIFICATION_ELEMENT=element;OR use.envfile:INTEGRATION_TENANT=tenant
INTEGRATION_CLIENT_ID=id
INTEGRATION_CLIENT_SECRET=secret
INTEGRATION_RESOURCE=resourse
INTEGRATION_AUTHORITY_HOST_URL=authority
INTEGRATION_LIVE_VERIFICATION_URL=verification
INTEGRATION_LIVE_VERIFICATION_ELEMENT=elementRun testsmake testLicensePlease seeLICENSEfile for details. requests_ms_auth is licensed under GNU AFFERO GENERAL PUBLIC LICENSE and has G-Faps.HistoryThis project grew from the needs of thelatigoproject.TODOscheck if MSAL method works;cover crucial parts with tests;clear Makefile;handle TODOs in the code;enable mypy for examples dir.
Package: requests-nber
Requests-NBER is a customRequestsclass to log ontoNBER.org, the website of the National Bureau of Economic Research.Installation$pipinstallrequests_nberDocumentationDetailed documentation available atwww.erinhengel.com/software/requests-nber.QuickstartTheNBERclass logs ontoNBER.organd establishes a connection with the host.
Contains asessionattribute that returns aRequest Session objectwith all the methods of the mainRequests API.>>>importrequests_nber# Establish NBER connection object.>>>deets={'username':'someuser','password':'XXXX'}>>>conn=requests_nber.NBER(login=deets)# Download the HTML of the paper with document id t1.>>>doc_id='t1'>>>html=conn.html(id=doc_id)# Download the document PDF.>>>pdf=conn.pdf(id=doc_id,file='article.pdf')# Download the bibliographic information.>>>biblio=conn.ref(id=doc_id)>>>biblio['doi']'10.3386/t0001'>>>biblio['author']'Seppo Honkapohja and Takatoshi Ito'
Package: requests-negotiate
# requests-negotiateAn implementation of HTTP Negotiate authentication ([RFC 4559](http://tools.ietf.org/html/rfc4559)) for [requests](http://docs.python-requests.org/en/latest/).Negotiate authentication is commonly used to provide Kerberos authentication through GSSAPI.## UsageHere’s a trivial example:import requests
import requests_negotiateauth = requests_negotiate.HTTPNegotiateAuth()
response = requests.get(’https://example.org/’, auth=auth)You’ll need a valid Kerberos ticket - acquired using e.g.kinit- for this to work.### OptionsYou can instantiate anHTTPNegotiateAuthwith the following optional parameters:service- A Kerberos principal is generally composed of a service name (e.g. ‘HTTP’) and a hostname, separated by a slash (‘/’). This lets you override the default service of'HTTP'.service_name- Overrides the full service name (e.g.'HTTP/example.org')negotiate_client_name- Explicitly specify which client principal to authenticate as. Particularly useful when you’re using a credential cache collection.
Package: requests-ntlm
This package allows for HTTP NTLM authentication using the requests library.UsageHttpNtlmAuthextends requestsAuthBase, so usage is simple:importrequestsfromrequests_ntlmimportHttpNtlmAuthrequests.get("http://ntlm_protected_site.com",auth=HttpNtlmAuth('domain\\username','password'))HttpNtlmAuthcan be used in conjunction with aSessionin order to
make use of connection pooling. Since NTLM authenticates connections,
this is more efficient. Otherwise, each request will go through a new
NTLM challenge-response.importrequestsfromrequests_ntlmimportHttpNtlmAuthsession=requests.Session()session.auth=HttpNtlmAuth('domain\\username','password')session.get('http://ntlm_protected_site.com')Installationpip install requests_ntlmRequirementsrequestspyspnegoAuthorsBen ToewsIan CordascoCory Benfield
Package: requests-ntlm2
requests-ntlm2NTLM authentication plugin for Requestsrequests-ntlm2, which is based onrequests-ntlm, allows for HTTP NTLM authentication using the requests library.Installationpipinstallrequests-ntlm2UsageBasic UsageHttpNtlmAuthextends requestsAuthBase, so usage is simple:importrequestsfromrequests_ntlm2importHttpNtlmAuthauth=HttpNtlmAuth('domain\\username','password')requests.get("http://ntlm_protected_site.com",auth=auth)Changing NTLM compatibility levelSee thisMS docon LM compatibility levels.requests_ntlm2defaults to
compatibility level 3 which supports NTLMv2 [only]. You can change the compatibility level as follows:importrequestsfromrequests_ntlm2importHttpNtlmAuth,NtlmCompatibilityusername='domain\\username'password='password123'ntlm_compatibility=NtlmCompatibility.LM_AND_NTLMv1_WITH_ESS# => level 1auth=HttpNtlmAuth(username,password,ntlm_compatibility=ntlm_compatibility)requests.get("http://ntlm_protected_site.com",auth=auth)Using with Requests SessionHttpNtlmAuthcan be used in conjunction with aSessionin order to
make use of connection pooling. Since NTLM authenticates connections,
this is more efficient. Otherwise, each request will go through a new
NTLM challenge-response.importrequestsfromrequests_ntlm2importHttpNtlmAuthsession=requests.Session()session.auth=HttpNtlmAuth('domain\\username','password')session.get('http://ntlm_protected_site.com')HTTP CONNECT UsageWhen usingrequests-ntlm2to create SSL proxy tunnel viaHTTP CONNECT, the so-called
"NTLM Dance" - ie, the NTLM authentication handshake - has to be done at the lower level
(athttpliblevel) at tunnel-creation step. This means that you should use theHttpNtlmAdapterand requests session. ThisHttpNtlmAdapteris responsible for sending proxy auth information
downstream.Here is a basic example:importrequestsfromrequests_ntlm2import(HttpNtlmAuth,HttpNtlmAdapter,NtlmCompatibility)username='...'password='...'proxy_ip='...'proxy_port='...'proxies={'http':'http://{}:{}'.format(proxy_ip,proxy_port),'https':'http://{}:{}'.format(proxy_ip,proxy_port)}ntlm_compatibility=NtlmCompatibility.NTLMv2_DEFAULTsession=requests.Session()session.mount('https://',HttpNtlmAdapter(username,password,ntlm_compatibility=ntlm_compatibility))session.mount('http://',HttpNtlmAdapter(username,password,ntlm_compatibility=ntlm_compatibility))session.auth=HttpNtlmAuth(username,password,ntlm_compatibility=ntlm_compatibility)session.proxies=proxiesresponse=session.get('http:/foobar.com')Requirementsrequestsntlm-auth
Package: requests-ntlm3
requests-ntlm3requests-ntlm3, which is based onrequests-ntlm, allows for HTTP NTLM authentication using the requests library.Installationpipinstallrequests-ntlm3UsageBasic UsageHttpNtlmAuthextends requestsAuthBase, so usage is simple:importrequestsfromrequests_ntlm3importHttpNtlmAuthauth=HttpNtlmAuth('domain\\username','password')requests.get("http://ntlm_protected_site.com",auth=auth)Changing NTLM compatibility levelSee thisMS docon LM compatibility levels.requests_ntlm3defaults to
compatibility level 3 which supports NTLMv2 [only]. You can change the compatibility level as follows:importrequestsfromrequests_ntlm3importHttpNtlmAuth,NtlmCompatibilityusername='domain\\username'password='password123'ntlm_compatibility=NtlmCompatibility.LM_AND_NTLMv1_WITH_ESS# => level 1auth=HttpNtlmAuth(username,password,ntlm_compatibility=ntlm_compatibility)requests.get("http://ntlm_protected_site.com",auth=auth)Using with Requests SessionHttpNtlmAuthcan be used in conjunction with aSessionin order to
make use of connection pooling. Since NTLM authenticates connections,
this is more efficient. Otherwise, each request will go through a new
NTLM challenge-response.importrequestsfromrequests_ntlm3importHttpNtlmAuthsession=requests.Session()session.auth=HttpNtlmAuth('domain\\username','password')session.get('http://ntlm_protected_site.com')HTTP CONNECT UsageWhen usingrequests-ntlm3to create SSL proxy tunnel viaHTTP CONNECT, the so-called
"NTLM Dance" - ie, the NTLM authentication handshake - has to be done at the lower level
(athttpliblevel) at tunnel-creation step. This means that you should use theHttpNtlmAdapterand requests session. ThisHttpNtlmAdapteris responsible for sending proxy auth information
downstream.Here is a basic example:importrequestsfromrequests_ntlm3import(HttpNtlmAuth,HttpNtlmAdapter,NtlmCompatibility)username='...'password='...'proxy_ip='...'proxy_port='...'proxies={'http':'http://{}:{}'.format(proxy_ip,proxy_port),'https':'http://{}:{}'.format(proxy_ip,proxy_port)}ntlm_compatibility=NtlmCompatibility.NTLMv2_DEFAULTsession=requests.Session()session.mount('https://',HttpNtlmAdapter(username,password,ntlm_compatibility=ntlm_compatibility))session.mount('http://',HttpNtlmAdapter(username,password,ntlm_compatibility=ntlm_compatibility))session.auth=HttpNtlmAuth(username,password,ntlm_compatibility=ntlm_compatibility)session.proxies=proxiesresponse=session.get('http:/foobar.com')Requirementsrequestsntlm-auth
Package: requests-oidc
Implements a simple API for creating a requestsSessionthat
manages your OIDC-discovered OAuth2 session for you.pip install requests-oidcfromrequests_oidcimportmake_auth_code_sessionfromrequests_oidc.pluginsimportOSCachedPluginoidc_url="https://your-oidc-provider.com/.well-known/openid-configuration"client_id="your-app"port=8675scope=["openid","email","profile"]plugin=OSCachedPlugin("your-app","your-company")session=make_auth_code_session(oidc_url,client_id,port,scope,plugin=plugin)PackagebuildGit
Package: requests-openapi
requests-openapiA lightweight but powerful and easy-to-use Python client library for OpenAPI v3.Key FeaturesLightweight Design: Experience a minimalistic interface.Focus on Essentials: Helps you simplify the handling of Paths, Parameters, Headers, Cookies, etc., while inheriting all the capabilities of Requests.Testing and Integration Made Easy: Whether you're running tests or integrating with other systems, the client simplifies these tasks.Usageimportrequests_openapi# load spec from urlc=requests_openapi.Client().load_spec_from_url("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml")# or load from filec=requests_openapi.Client().load_spec_from_file("openapi.json")# set serverc.set_server(requests_openapi.Server(url="https://fake.com/api"))# custom session for auth or othersc.requestor# a instance of requests.Session, see https://requests.readthedocs.io/en/latest/user/advanced/#session-objects# set update tokenc.requestor.headers.update({"Authorization":"token"})# call api by operation idresp=c.listPets()# resp: requests.Responseresp.json()# get by path idresp=c.showPetById(petId=1)resp.json()# postresp=c.createPets(json={})resp.json()## Advanced Usage## set req options, 'req_opts' param to custom request optionsrequests_openapi.Client(req_opts={"timeout":60}).load_spec_from_file("xx")# parameters starts with '_' or not found in openapi spec, will be passed through to the requestingc.createPets(json={},_headers={},_params={},_cookies={})# parameters# in: cookie, name: csrftokenc.createPets(csrftoken="***")# in: header, name: x-fooc.createPets(**{"x-foo":"***"})# in: path, name: userIdc.getUser(userId=1)# in: query, name: offsetc.listUsers(offset=1)# http body, just like requests.Sessionc.createPets(json={})orc.createPets(data={})Installationpip install requests-openapiLicenseMIT