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.
The 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 the external web services with SharePoint, so I felt to delegate the token generation process to an external tool and consume the Authentication Token directly without keeping username 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 displays it in the “Authentication Token” section.

Now, let’s discuss the code for this functionality.
Step 1 - registering the button click event by mapping a function “get Token”.
Step 2 - calling the “getBasicAuthenticationToken” function by passing the username and password.
Step 3 - preparing the format required to convert plain text into hash value in base-64 format.
Step 4 - calling JavaScript function “btoa” which will encode the plain text into “base-64” format, a required hash value to prepare Basic Authentication Token.



Join the conversation! Your thoughts help the community grow.