basic-authentication

Calling WEB API with basic authentication in C#

三世轮回 提交于 2020-06-12 16:43:31
问题 I have a working WEB API that I wrote, and I added basic authentication to the API (username is "testing", password is "123456"). However, when trying to call that API from my web form, I keep getting the "(401) Unauthorized" message. What should I change in the web code to call the API successfully? string url = String.Format("http://example.com"); //here I have the correct url for my API HttpWebRequest requestObj = (HttpWebRequest)WebRequest.Create(url); requestObj.Method = "Get";

Calling WEB API with basic authentication in C#

我与影子孤独终老i 提交于 2020-06-12 16:43:09
问题 I have a working WEB API that I wrote, and I added basic authentication to the API (username is "testing", password is "123456"). However, when trying to call that API from my web form, I keep getting the "(401) Unauthorized" message. What should I change in the web code to call the API successfully? string url = String.Format("http://example.com"); //here I have the correct url for my API HttpWebRequest requestObj = (HttpWebRequest)WebRequest.Create(url); requestObj.Method = "Get";

Django: Basic Auth for one view (avoid middleware)

爷,独闯天下 提交于 2020-05-11 04:04:40
问题 I need to provide http-basic-auth to one view. I want to avoid modifying the middleware settings. Background: This is a view which gets filled in by a remote application. 回答1: When you do a basic auth request, you're really adding credentials into the Authorization header. Before transit, these credentials are base64-encoded, so you need to decode them on receipt. The following code snippet presumes that there's only one valid username and password: import base64 def my_view(request): auth

Django: Basic Auth for one view (avoid middleware)

空扰寡人 提交于 2020-05-11 04:02:34
问题 I need to provide http-basic-auth to one view. I want to avoid modifying the middleware settings. Background: This is a view which gets filled in by a remote application. 回答1: When you do a basic auth request, you're really adding credentials into the Authorization header. Before transit, these credentials are base64-encoded, so you need to decode them on receipt. The following code snippet presumes that there's only one valid username and password: import base64 def my_view(request): auth

Authentication based dynamically on Authorization header-scheme in non-MVC Asp.Net Core 2.x

こ雲淡風輕ζ 提交于 2020-03-23 08:55:14
问题 I'm creating an API, which does not use MVC , but rather generic middleware(s). It should be possible to be authenticated against both Basic and (Jwt) Bearer scheme (I'm aware of the security flaws of Basic Auth) I can easily register both schemes in the services, but app.UseAuthentication middleware will only attempt to authenticate against the default scheme (this is intentional and described in the documentation). Allowing multiple scheme for the same endpoint can be done in MVC by

Android| Basic Auth using retrofit2 and local API

最后都变了- 提交于 2020-02-28 15:41:49
问题 I started making an app and connected it to a mock API at first. Now I want to connect it an API that runs on my PC. For starters, I'm trying to implement the login access. Since my API's base URL was http://localhost:5000/energy/api/ I changed it to http://<< MyIPAddress >>:5000/energy/api/ (don't know if this is right yet). I'm testing it on my actual phone. But with my code username and password are passed on as parameters, while I'd like to login with basic auth (this is how I do it in

Android| Basic Auth using retrofit2 and local API

青春壹個敷衍的年華 提交于 2020-02-28 15:36:02
问题 I started making an app and connected it to a mock API at first. Now I want to connect it an API that runs on my PC. For starters, I'm trying to implement the login access. Since my API's base URL was http://localhost:5000/energy/api/ I changed it to http://<< MyIPAddress >>:5000/energy/api/ (don't know if this is right yet). I'm testing it on my actual phone. But with my code username and password are passed on as parameters, while I'd like to login with basic auth (this is how I do it in

How do I automatically authorize all endpoints with Swagger UI?

☆樱花仙子☆ 提交于 2020-02-24 05:42:55
问题 I have an entire API deployed and accessible with Swagger UI. It uses Basic Auth over HTTPS, and one can easily hit the Authorize button and enter credentials and things work great with the nice Try it out! feature. However, I would like to make a public sandboxed version of the API with a shared username and password, that is always authenticated; that is, no one should ever have to bring up the authorization dialog to enter credentials. I tried to enter an authorization based on the answer

Set up private yum repo with basic auth

て烟熏妆下的殇ゞ 提交于 2020-02-18 22:20:09
问题 I have set my own private yum repo. This is an HTTP base repo with a Apache as a web server, so I would like to add some kind of authentication. Is this something I need to do with Apache or is there anything I can do with the createrepo library to specify a user-name and password? The final goal is to have several repos: Dev-Repo, QA-Repo, Staging-Repo, and Production-Repo I want developers to have access to only the dev-repo, have QA access only QA-Repo and so on... 回答1: To setup basic auth

Web Api won't download file using jQuery Ajax and Basic Auth

徘徊边缘 提交于 2020-01-29 05:37:04
问题 I am using the ASP.NET Web API to build a prototype of a web service (and site) which has a method to download a file. When the user on the front-end presses the export button a jQuery ajax GET request is made and received by the controller which on it's turn calls the method named Excel (shown below). The method runs without any problem and finishes. When I look in Chrome at the header (see https://skydrive.live.com/redir?resid=2D85E5C937AC2BF9!77093) it receives the response with (as far as