Register at http://register.directauth.io to get your verifier spun up today!
Try our hosted example here​
To allow your web app to retrieve keys from the Torus Network, we'll be using the direct-web-sdk, the repo itself has examples that you can also refer to:
Install the package npm i @toruslabs/torus-direct-web-sdk
Serve service worker from baseUrl
where baseUrl is the one passed while instantiating DirectWebSdk
for specific login (example http://localhost:3000/serviceworker/). If you're already using a sw, pls ensure to port over the fetch override from our service worker​
For browsers where service workers are not supported or if you wish to not use service workers, create and serve redirect page from baseUrl/redirect
where baseUrl is the one passed while instantiating DirectWebSdk
for specific login ( example http://localhost:3000/serviceworker/)
At verifier's interface (where you obtain client id), please use baseUrl/redirect
(eg: http://localhost:3000/serviceworker/redirect) as the redirect_uri where baseUrl is the one passed while instantiating DirectWebSdk
Instantiate the package with your own specific client-id
const torus = new DirectWebSdk({baseUrl: "http://localhost:3000/serviceworker/",proxyContractAddress: "0x4023d2a0D330bF11426B12C6144Cfb96B7fa6183", // details for test netnetwork: "ropsten", // details for test net});await torus.init();
6. Trigger the login
const userInfo = await torus.triggerLogin({typeOfLogin: "google",verifier: "google",clientId: "MY CLIENT ID GOOGLE",});
If you're building a chrome extension or electron app, please set redirectToOpener: true
and modify the origin of postMessage from "http://localhost:3000"
to your hosted domain in redirect.html and sw.js. (This allows the popup to redirect to your app if the communication to opener window fails)
For integration into other mobile, native or other platforms please refer to Integrating DirectAuth.
Firstly, register your app with OAuth login providers. There are two types of providers which Torus supports. Click on the links to see instructions on how to configure OAuth provider.
Native providers allow you to register your app directly with implicit grant support and use with Torus. The following are the supported native providers
For native providers, please provide us with the client/app ID registered with the provider.
Proxy providers require you to register your app on OAuth provider and add some config on their app. Proxy providers enable you to use some non-implicit type logins. (e.g: Twitter, Apple, GitHub, LinkedIn, Email-Password, Magic link, WeChat etc.) Some examples of proxy providers
For proxy providers, please provide us with the Client ID, Authentication domain provided by the proxy provider.
Register at http://register.directauth.io to get your verifier spun up today!
​