An async python client for my "Purple Auth" microservice.
The basics are outlined below, or you can look at an example
Create an account and application on purpelauth.com, then initialize the client with those values. You should store the api key in an environment variable, but the app id is a public value, not a secret.
import (
purpleauth "github.com/rick94/go-pa-client"
)
func main() {
client := purpleauth.NewClient("https://purpleauth.com", "My-App-ID", "My-API-Key")
}
You will initially be limited to 500 authentications per app, but you can email me to have that increased.
Start otp authentication flow with server. This will send a one time code to the user's email.
if err := client.Authenticate("[email protected]", "otp"); err != nil {
log.Fatal(err)
}
Complete authentication with email and generated code submitted by the user.
token, err := client.SubmitCode("[email protected]", "123456")
Send idToken to server for verification.
claims, err := client.VerifyTokenRemote(idTokenFromClient)
You should prefer to verify tokens locally using the VerifyToken
function, but
this is provided as a convenience and sanity check.
Request a new ID Token from the server using a refresh token
newToken, err := client.Refresh(refreshTokenFromClient)
Get more info about this app from the server.
info = client.GetAppInfo()
Start authentication using magic link flow.
if err := client.Authenticate("[email protected]", "otp"); err != nil {
log.Fatal(err)
}
Verify and decode an ID Token on directly in the app without having to call out every time
claims, err := client.VerifyToken(idTokenFromClient)