Browse Source

Add recovery code API

master
harture 6 years ago
committed by GitHub
parent
commit
9f5a2b117b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      recovery_code.go

20
recovery_code.go

@ -0,0 +1,20 @@
package keycloak
import "gopkg.in/h2non/gentleman.v2/plugins/url"
import "gopkg.in/h2non/gentleman.v2/plugins/query"
const (
recoveryCodePath = "/auth/realms/:realm/recovery-code"
)
type RecoveryCodeRepresentation struct {
Code *string `json:"code,omitempty"`
}
// CreateRecoveryCode creates a new recovery code authenticator and returns the code.
func (c *Client) CreateRecoveryCode(accessToken string, realmName string, userID string) (RecoveryCodeRepresentation, error) {
var resp = RecoveryCodeRepresentation{}
_, err := c.post(accessToken, &resp, query.Add("userId", userID), url.Path(recoveryCodePath), url.Param("realm", realmName))
return resp, err
}
Loading…
Cancel
Save