Skip to content

CeoFred/fast-otp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

9f39657 · Feb 7, 2024

History

24 Commits
Jan 27, 2024
Feb 7, 2024
Jan 23, 2024
Jan 22, 2024
Feb 7, 2024
Feb 7, 2024
Feb 7, 2024
Feb 7, 2024
Jan 27, 2024
Feb 7, 2024
Feb 7, 2024
Feb 7, 2024
Feb 7, 2024

Repository files navigation

Go FastOTP

FastOTP is a Go library for interacting with the FastOTP API to generate one-time passwords (OTPs) easily.

Installation

go get -u github.com/CeoFred/[email protected]

Usage

Basic Example

package main

import (
	"fmt"
	"log"

	"github.com/CeoFred/fast-otp"
)

func main() {
	// Replace "your_api_key" with your actual FastOTP API key
	apiKey := "your_api_key"

	// Create an instance of FastOtp
	client := fastotp.NewFastOTP(apiKey)

	// Create context for library functions
	ctx := context.Background()

	// Define OTP generation payload
	payload := fastotp.GenerateOTPPayload{
    Delivery: OtpDelivery{
      "email": "[email protected]",
    },
		Identifier:  "user123",
		TokenLength: 6,
		Type:        "numeric",
		Validity:    120,
	}

	// Generate OTP
	otp, err := client.GenerateOTP(ctx, payload)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Generated OTP: %s\n", otp)

  // Validate OTP
  otp, err = client.ValidateOTP(
	 ctx,
     ValidateOTPPayload{
        Identifier: "user123",
        Token: "123456",
    }
  )
	if err != nil {
		log.Fatal(err)
	}

  fmt.Printf("Otp validation status: %s\n", otp.Status)
}

API Documentation

For detailed information about the FastOTP API and available endpoints, refer to the official API documentation.

Configuration

  • APIKey: Your FastOTP API key.

Contributing

If you'd like to contribute to this project, please follow the guidelines in CONTRIBUTING.md.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to the FastOTP team for providing the awesome OTP generation service.