Securely Exposing C# REST API to scripting language such as Python
c#, python, rest, security
Solution
Use exactly the same authentication method you are currently using.
Here is a basic example using python (untested):
from requests.auth import HTTPBasicAuth
s = requests.Session()
# Make the initial authentication request from a session object
s.get('https://omg.wtf/user', auth=HTTPBasicAuth('user', 'pass'))
# All subsequent requests from that session will include any cookies set in the initial response
r = s.get('http://omg.wtf/911')
print(r.text)
Problem
My C# REST API are called from an AngularJS web app. I secure the Web API by authenticating the user and ensuring the user is part of a specific windows group. Now the customer would like the option of calling the API from scripts (Python). How do I implement this? Should I just get them to pass username and password as part of the json call?