Back to Support Center

Authentication

Secure authentication methods for accessing Kisan AI's services.

Email & Password

Traditional authentication using email and password

  1. 1
    User submits email and password
  2. 2
    Server validates credentials
  3. 3
    JWT token is generated
  4. 4
    Token is returned to client

API Key Authentication

Secure API access using API keys

  1. 1
    Generate API key in dashboard
  2. 2
    Include key in request header
  3. 3
    Server validates API key
  4. 4
    Access granted to resources

Token Refresh

Maintaining secure sessions with token refresh

  1. 1
    Access token expires
  2. 2
    Use refresh token to request new access token
  3. 3
    Validate refresh token
  4. 4
    Issue new access token

Implementation Examples

JavaScript
const login = async (email, password) => {
  const response = await fetch('/api/auth/login', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ email, password })
  });
  
  const { token } = await response.json();
  return token;
};
Python
import requests

def login(email, password):
    response = requests.post(
        'https://api.kisanai.com/auth/login',
        json={'email': email, 'password': password}
    )
    return response.json()['token']

Security Best Practices

Token Storage

Store tokens securely in HttpOnly cookies or secure storage

API Key Protection

Never expose API keys in client-side code or repositories

Regular Rotation

Rotate API keys periodically and after team member changes

Error Handling

Implement proper error handling for authentication failures

Ready to Implement?

Start integrating secure authentication in your application.