Files
m3o-go/examples/otp/README.md
2022-02-20 21:54:04 +00:00

961 B
Executable File

Otp

An m3o.com API. For example usage see m3o.com/otp/api.

Endpoints:

Validate

Validate the OTP code

https://m3o.com/otp/api#Validate

package example

import(
	"fmt"
	"os"

	"go.m3o.com/otp"
)

// Validate the OTP code
func ValidateOtp() {
	otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := otpService.Validate(&otp.ValidateRequest{
		Code: "656211",
Id: "asim@example.com",

	})
	fmt.Println(rsp, err)
	
}

Generate

Generate an OTP (one time pass) code

https://m3o.com/otp/api#Generate

package example

import(
	"fmt"
	"os"

	"go.m3o.com/otp"
)

// Generate an OTP (one time pass) code
func GenerateOtp() {
	otpService := otp.NewOtpService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := otpService.Generate(&otp.GenerateRequest{
		Id: "asim@example.com",

	})
	fmt.Println(rsp, err)
	
}