mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-21 14:35:01 +00:00
Commit from m3o/m3o action
This commit is contained in:
61
examples/otp/README.md
Executable file
61
examples/otp/README.md
Executable file
@@ -0,0 +1,61 @@
|
||||
# Otp
|
||||
|
||||
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Otp/api](https://m3o.com/Otp/api).
|
||||
|
||||
Endpoints:
|
||||
|
||||
## Generate
|
||||
|
||||
Generate an OTP (one time pass) code
|
||||
|
||||
|
||||
[https://m3o.com/otp/api#Generate](https://m3o.com/otp/api#Generate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
```
|
||||
## Validate
|
||||
|
||||
Validate the OTP code
|
||||
|
||||
|
||||
[https://m3o.com/otp/api#Validate](https://m3o.com/otp/api#Validate)
|
||||
|
||||
```go
|
||||
package example
|
||||
|
||||
import(
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/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)
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user