Tutorial
XRPL
Firebase Authentication

Set up Firebase Authentication (Twitter)

Set up your Twitter App

Alt text

  • In the Consumer Keys field click the Regenerate button to obtain the Client ID and Client secret.

Alt text

Set up Firebase Console

Alt text

  • Go to project settings and obtain the Firebase config details. Add these to the .env file of the next.js project.

Alt text

Alt text

Add Twitter authentication to the Firebase project

  • Go to the Authentication tab and navigate to the Sign-in Method section. Select Twitter as the sign-in provider.

Alt text

  • Add the obtained Client ID as the API key and the Client Secret as the API secret when creating the Twitter app. Then, obtain the Callback URL.

Alt text

  • Add the obtained Callback URL as the “Redirect URL” in the Twitter App.

    • Navigate to the app created in the Twitter Developer portal.

    • Navigate to the “user authentication setup”.

      Alt text

    • In the “App permission” section give only “Read” access.

    • Then Enable “Request email from users”.

    • Select “Web app” as the type of app.

    • In the “App Info” section as the “Callback URI / Redirect URL” add the obtained Callback URL from the firebase.

    • Add your website URL in the “Website URL” field.

Obtain a JWT token

  • Navigate to “twitter-login”.

    cd twitter-login\next-js

  • Run the project.

    yarn dev

  • Click the Sign in with Twitter Button to obtain the JWT token

    • Click the Sign in with Twitter Button
    • Login with Twitter
    • Open the developer-tools => console, to get the JWT token

    Alt text

    Note

    Here you will not be redirected to the homepage of the application since you have not configured the Kaiju Developer Portal (opens in a new tab). Please ignore any errors at this stage.If you do not get the JWT token please clear the Cookies in http:localhost:3000 at Developer-Tools => Application => Cookies by right-clicking on the http://localhost:3000 (opens in a new tab).

Set up your Kaiju Developer Portal

Alt text

  • Fill out the fields and click the "Create Project" button.

Alt text

  • Navigate to the 'Settings' tab in the sidebar and obtain the Access Key.

Alt text

Alt text

Run the project

  • Run the project.

    yarn dev

  • Login with Twitter, and you will navigate to the home page. You can see your wallet details and can do a transaction from there.

ℹ️

At login, the application receives the user ID Token (User Token) and passes it to the getWallet and signTransaction APIs. This ID Token must include the email as a claim.

Add More Social Providers

  • Add social providers like (Google, Apple, Github, Game Center, Microsoft, Twitter, Yahoo and Email) providers to the Firebase.

  • Update the code at src/app/login/page.tsx to use the respective provider.

    Alt text

Also check the Login Flow , Transaction Flow and Go to Live .

You can refer the below video for a step-by-step guide on how to set up Firebase Authentication.