GoodDocs
  • Welcome to GoodDocs!
  • GoodDollar Ecosystem Vision
  • About the Protocol
    • Usage
    • Tokenomics
    • Sybil-Resistance
    • Protocol V3 Documentation
      • Architecture & Value Flow
      • System's Elements
      • Core Contracts & API
        • GoodDollar
        • GoodCompoundStaking V2 (DAI)
        • GoodAaveStaking V2 (USDC)
        • GoodReserveCDai
        • GoodFundManager
        • GoodMarketMaker
        • ContributionCalculation
        • UBIScheme
        • Identity
        • FirstClaimPool
        • AdminWallet
        • OneTimePayments
        • DonationsStaking
        • NameService
        • GReputation
        • CompoundVotingMachine
        • StakersDistribution
        • UniswapV2SwapHelper
        • Invites
        • GovernanceStaking
        • ClaimersDistribution
        • CompoundStakingFactory
        • AaveStakingFactory
        • ExchangeHelper
        • FuseFaucet
        • GoodDollarMintBurnWrapper
      • Previous Protocol Versions
        • Protocol V1
          • Architecture & Value Flow
          • Core Contracts & API
        • Protocol V2
          • Architecture & Value Flow
          • System's Elements
            • 1. The token (G$)
            • 2. The Reserve
            • 3. The Trust
            • 4. Staking rewards (APR)
            • 5. The Fund Manager
            • 6. The Distribution Contract (DisCo)
            • 7. Governance (DAO)
          • Core Contracts & API
            • GoodDollar
            • GoodCompoundStaking V2 (DAI)
            • GoodAaveStaking V2 (USDC)
            • GoodReserveCDai
            • GoodFundManager
            • GoodMarketMaker
            • ContributionCalculation
            • UBIScheme
            • Identity
            • FirstClaimPool
            • AdminWallet
            • OneTimePayments
            • DonationsStaking
            • NameService
            • GReputation
            • CompoundVotingMachine
            • StakersDistribution
            • UniswapV2SwapHelper
            • Invites
            • GovernanceStaking
            • ClaimersDistribution
            • CompoundStakingFactory
            • AaveStakingFactory
            • ExchangeHelper
            • FuseFaucet
  • User Guides
    • Buy & Sell G$
    • Stake to create UBI
    • Claim GOOD and G$X
    • Bridge GoodDollars
    • Connect another wallet address to identity
  • Liquidity
  • Wallet and Products
    • GoodWallet
    • GoodDapp
    • New GoodWallet
    • GoodCollective
    • GoodID & GoodOffers
    • 3rd Party Partners and Integrations
  • Frequently Asked Questions
    • Web3 basic knowledge and security tips - by Consensys
    • About GoodDollar
    • GoodDollar Protocol & G$ Token
    • Using GoodDollar
    • GoodDollar Community
    • Troubleshooting
  • For Developers
    • Contributing to GoodDollar
    • GoodDapp Developer Guides
      • Deploy your own GoodDapp UI
    • APIs & SDKs
      • Claim UBI
      • React Hooks Setup
      • Login With GoodDollar
      • Sybil Resistance
        • Identity (Ethers v5 / React)
        • Identity (Viem/Wagmi)
  • Useful Links
    • GoodDollar.org
    • GoodDapp
    • GoodWallet
    • GoodDollar User Guides
    • Statistics Dashboard
    • GoodDollar Whitepaper
    • GoodDollar Litepaper
    • GoodDollar Litepaper - Español
Powered by GitBook
On this page
  • GoodDollar Login SDK
  • Install
  • SDK Utilities
  • Object schema for createLoginLink
  • Object schema for useLogin
  • Props for LoginButton
  • example login with hook
  • example login with button

Was this helpful?

  1. For Developers
  2. APIs & SDKs

Login With GoodDollar

An SDK that allows the user to share his details

PreviousReact Hooks SetupNextSybil Resistance

Last updated 3 months ago

Was this helpful?

GoodDollar Login SDK

This is the gooddollar client sdk for integrating login into gooddollar in your website

  • to test the functionality

Install

yarn add @gooddollar/login-sdk

SDK Utilities

  • createLoginLink to generate login link to redirect to the gooddollar wallet

  • LoginButton to place a login button on your page to integrate login with gooddollar on your website

  • parseLoginResponse to verify if the login was successful and verified

  • useLogin is a hook that can be used instead of button to integrate login with gooddollar on your website

Object schema for createLoginLink

Property Name
Purpose
Mandatory/Optional
Type

redirectLink

gooddollar wallet link to redirect to

Optional

String

v

name of the vendor

Mandatory

String

web

web link for vendor

Mandatory

String

id

wallet address for vendor

Mandatory

String

r

array of information ex.['mobile','location']

Mandatory

array

cbu

Callback URL

provide either rdu or cbu

String

rbu

Redirect URL

provide either rdu or cbu

String

Object schema for useLogin

Property Name
Purpose
Mandatory/Optional
Type

gooddollarlink

wallet link returned by createLoginLink

Mandatory

String

cbu

Callback URL

provide either rdu or cbu

String

rbu

Redirect URL

provide either rdu or cbu

String

onLoginCallback

Function that has the data returned by wallet as the first argument

Mandatory

Function

Props for LoginButton

Prop Name
Purpose
Mandatory/Optional
Type

gooddollarlink

wallet link returned by createLoginLink

Mandatory

String

cbu

Callback URL

provide either rdu or cbu

String

rbu

Redirect URL

provide either rdu or cbu

String

onLoginCallback

Function that has the data returned by wallet as the first argument

Mandatory

Function

example login with hook

import {
  useLogin,
  createLoginLink,
  parseLoginResponse,
} from "@gooddollar/goodlogin-sdk";

const App() {
  const gooddollarLink = createLoginLink({
    v: "Google",
    web: "https://gooddollar.netlify.app",
    id: "0x09D2011Ca5781CA70810F6d82837648132762F9a",
    r: ["mobile", "location", "email", "name"],
    rdu: "https://gooddollar.netlify.app",
  });

  const loginCallBack = async (data) => {
    //to check if login response is valid or not 
    parseLoginResponse(data)
  }

  const onClick =  useLogin({
    rdu: gooddollarLink,
    gooddollarlink: rest.gooddollarlink,
    onLoginCallback: onLoginCallback,
  });

  return (
    <div className="App">
      <button onClick={onClick}>Login With Gooddollar</button>
    </div>
  );
}

example login with button

import {useState} from 'react';
import {
  LoginButton,
  createLoginLink,
  parseLoginResponse,
} from "@gooddollar/goodlogin-sdk";

function App() {
  const gooddollarLink = createLoginLink({
    v: "Google",
    web: "https://gooddollar.netlify.app",
    id: "0x09D2011Ca5781CA70810F6d82837648132762F9a",
    r: ["mobile", "location", "email", "name"],
    rdu: "https://gooddollar.netlify.app",
  });

  const [gooddollarData, setGooddollarData] = useState({});

  return (
    <div className="App">
        {Object.keys(gooddollarData).length === 0 ? (
          <>
            <LoginButton
              onLoginCallback={async (data) => {
              //to check if login response is valid or not 
              parseLoginResponse(data)
              setGooddollarData(data)
              }}
              gooddollarlink={gooddollarLink}
              style={{ fontSize: 20, padding: 20 }}
              rdu="gasdasd"
            >
              Loggin With GOODDOLLAR
            </LoginButton>
          </>
        ) : (
          <div>
            <p>Logged In</p>
            <p>Name : {gooddollarData.fullName}</p>
            <button
              onClick={() => {
                setGooddollarData({});
                window.location.href = "https://gooddollar.netlify.app";
              }}
              style={{ fontSize: 20, padding: 20 }}
            >
              Logout
            </button>
          </div>
        )}
    </div>
  );
}
https://github.com/GoodDollar/GoodWeb3-Mono/tree/master/packages/login-sdk
Example App
Source Code to the example app