This project integrate Web3Auth with Microsoft OAuth for authentication. Web3Auth is a decentralized authentication protocol that allows users to sign in to applications using their Ethereum wallets. In this demo, Microsoft OAuth is used to authenticate users, and Web3Auth is employed to provide Ethereum private key access and public address.
Follow these steps to set up and run the project:
git clone https://github.com/rtomas/microsoft-oauth-for-web3auth.git
cd microsoft-oauth-for-web3auth
npm install
3. Configure the verifier in the Web3Auth Dashboard
Choose a name an use it for the ENV Configuration. Then select in Login Provider as "Custom Provider" and configure the other information as you can see in the image.
Upload the jwks.json to a server. In my example was uploaded to github.
You'll need the Application (client) ID and the Directory (tenant) ID. Then you can add a redirect URI (in our example is http://localhost:5005/ms/callback)
Finally in "Certificates & secrets" -> Client Secret -> New client secret and copy the value to the .ENV
Follow the instructions from this link: https://web3auth.io/docs/auth-provider-setup/byo-jwt-providers#how-to-convert-pem-to-jwks
AZURE_CLIENT_ID=## create one in https://entra.microsoft.com/##
AZURE_CLIENT_SECRET=## create one in https://entra.microsoft.com/##
AZURE_TENANT_ID=## create one in https://entra.microsoft.com/##
AZURE_CODE_CHALLENGE=##create pair with CODE_VERIFIER in https://tonyxu-io.github.io/pkce-generator/##
AZURE_CODE_VERIFIER=##create pair with CODE_CHALLENGE in https://tonyxu-io.github.io/pkce-generator/##
PRIVATE_KEY_FILE_NAME=privateKey.pem
JWKS_FILE_NAME=jwks.json
npm run dev
Open your browser and navigate to http://localhost:5005/ms/login to initiate the Microsoft OAuth flow.
When integrating Web3Auth with Microsoft Login the flow looks something like this: