This demo is about another tool that I worked out during an assignment while working with an integration scenario using web services supporting Basic Authentication.
Problem with basic authentication is that you have to keep username and password stored somewhere in order to generate the authentication token.
Since I was integrating external web services with SharePoint so I felt to delegate the Token Generation Process to an external tool and consume the Authentication Token directly with out keep user name and password to be stored in the code itself.
To run this demo I have created a simple interface that takes username and password as input and generates the Basic Authentication Token and will display it in “Authentication Token” section
Now let’s discuss the code behind this functionality:
Step 1 is registering button click event by mapping a function “get Token”
Step 2 is calling “getBasicAuthenticationToken” function by passing user name and password
Step 3 is preparing format required to convert plain text into hash value in base-64 format
“Basic” is prefixed to the hash value to comply with Basic Authentication Token Standards
That is it for the code.
Now when we click “Get Authentication Token” button we will see the authentication token in the “Authentication Token” section.
This token can be used for any Web Service supporting basic authentication, and this strategy can be merged with other functionalities too in order to generate this token on the fly.
Hope you find it helpful.