This commit is contained in:
afkarxyz
2026-04-14 07:36:41 +07:00
parent 59a057b14a
commit 7346730be9
336 changed files with 13800 additions and 1142 deletions
+28
View File
@@ -0,0 +1,28 @@
package backend
import (
"fmt"
"time"
"github.com/pquerna/otp"
"github.com/pquerna/otp/totp"
)
const (
spotifyTOTPSecret = "GM3TMMJTGYZTQNZVGM4DINJZHA4TGOBYGMZTCMRTGEYDSMJRHE4TEOBUG4YTCMRUGQ4DQOJUGQYTAMRRGA2TCMJSHE3TCMBY"
spotifyTOTPVersion = 61
)
func generateSpotifyTOTP(now time.Time) (string, int, error) {
key, err := otp.NewKeyFromURL(fmt.Sprintf("otpauth://totp/secret?secret=%s", spotifyTOTPSecret))
if err != nil {
return "", 0, err
}
code, err := totp.GenerateCode(key.Secret(), now)
if err != nil {
return "", 0, err
}
return code, spotifyTOTPVersion, nil
}