2. Connect to SIWW

In our nodeJS app, we will create a /authenticate directory, in which we will locate all relevant authentication files that we create for our purpose.

In the authenticate directory, create a file named passport_siww.js and add the code for managing the SIWW authentication strategy.

// make use of passport-wallet strategy
const passport = require('passport');
const SIWWStrategy = require("@incubiq/passport-wallet").Strategy;

// our settings to connect with SIWW
const myDomain="https://mydomain.com/";          // replace by your domain here
const cSIWW={
    clientID: "7TdKmdPQ1663168239850",           // insert your client ID here
    clientSecret: "",                            // insert your client secret here
    callbackURL:myDomain+"auth/siww/callback",   // do not change this
    host: "https://signwithwallet.com/",         // do not change this
    domain: "signwithwallet.com",                // do not change this

// register strategy
passport.use(new SIWWStrategy({
    clientID: cSIWW.clientID,                                    // our app_id
    clientSecret: cSIWW.clientSecret,                            // our app_secret (only used if enableProof is true)
    callbackURL: cSIWW.callbackURL,                              // our callback URL
    enableProof: true,                                           // set to true to make use of the app_secret to secure calls (false = unsecured calls)
    authorizationURL: cSIWW.host+ "oauth/dialog/authorize",      // where we call SIWW for authorization (fixed URL)
    tokenURL: cSIWW.host+"oauth/token",                          // where we call SIWW for getting oAuth token (fixed URL)
    profileURL: cSIWW.host+"oauth/resources/profile"             // where we call SIWW for receivinend use's profile (fixed URL)
    function(accessToken, refreshToken, profile, done) {
        try {
            if(!profile) {
                return done(null, false, {});       // got in error...

            let wallet_address= profile && profile.wallet_address ? profile.wallet_address : null;

            // TODO define what to validate here

            // happy with validations? Create the user
            // TODO : here we call an undefined libUser, replace by your user creation library
                username: profile.username, 
                connector: profile.connector,
                blockchain: profile.blockchain,
                wallet_id: profile.wallet,
                wallet_address: wallet_address,
                authorizations: profile.authorizations,
                isValidated: true
                    process.nextTick(function () {
                        return done(null, obj.data);
                    return done(null, false, obj.statusText);
        catch (err) {
            return done(null, false, err);

module.exports = passport;

Last updated