Skip to content

manolo-in/better-auth-zoho

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cover

better-auth-zoho

Zoho Provider for Better-Auth. Wrapper around Generic OAuth plugin.

This package allow you to easily add Zoho OpenID Connect (OIDC) flow to your application.

Installation

npm i better-auth-zoho

Zoho Setup

  1. Go to Zoho API Console
  2. Login with your Zoho Account
  3. Create a Server Based Application
  4. Paste these details
# For Local Development

Client Name: MyApp
Homepage URL: http://localhost:3000

Authorized Redirect URIs: http://localhost:3000/api/auth/oauth2/callback/zoho
  1. Copy credentials to your .env file
ZOHO_CLIENT_ID="*****************"
ZOHO_CLIENT_SECRET="*************"

Usage

import { betterAuth } from "better-auth";
import { zohoPlugin } from "better-auth-zoho";

export const auth = betterAuth({
    plugins: [
        zohoPlugin({
            location: "in" // App DataCenter
        }),
    ],
});

Client Side

import { createAuthClient } from "better-auth/client"
import { genericOAuthClient } from "better-auth/client/plugins"
import type { auth } from "./auth";

export const authClient = createAuthClient({
    plugins: [
        inferAdditionalFields<typeof auth>(), // optional
        genericOAuthClient() // required
    ]
})
import { authClient } from "./lib/auth";

await authClient.signIn.oauth2({
    providerId: "zoho"
});

Advanced Config

import { betterAuth } from "better-auth";
import { genericOAuth } from "better-auth/plugins";
import { zoho } from "better-auth-zoho";

export const auth = betterAuth({
    plugins: [
        genericOAuth({
            config: [
                zoho({
                    // 'in' for India DC (https://accounts.zoho.in)
                    // 'us' for United States DC (https://accounts.zoho.com)
                    location: "in",
                    scopes: ["email", "phone", "profile", "openid"],
                    clientId: process.env.ZOHO_CLIENT_ID,
                    clientSecret: process.env.ZOHO_CLIENT_SECRET
                }),

                // Add more providers as needed
            ]
        }),
    ],
});

Resources

Make sure to read docs from Zoho OAuth before setup.

About

Zoho OAuth Provider for Better-Auth

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published