// ParseFromString creates a new Token from its plaintext string
ParseFromString creates a new Token from its plaintext string
// ParseFromString creates a new Token from its plaintext string
func (t *GrantToken) ParseFromString(s string) error {
	parts := strings.Split(s, ":")
	if len(parts) < 1 {
		return fmt.Errorf("invalid token")
	}
	version := parts[0]
	domain := ""
	secret := ""
	switch version {
	case "v1":
		if len(parts) != 3 {
			return fmt.Errorf("failed to run ParseDomain, invalid token")
		}
		domain = parts[1]
		secret = parts[2]
	default:
		return fmt.Errorf("failed to run ParseDomain, invalid version %s", version)
	}
	t.Version = version
	t.Domain = domain
	t.secret = secret
	return nil
}
func ( t * GrantToken ) ParseFromString ( s string ) error { parts := strings . Split ( s , " " ) if len ( parts ) < 1 { return fmt . Errorf ( " " ) } version := parts [ 0 ] domain := " " secret := " " switch version { case " " : if len ( parts ) != 3 { return fmt . Errorf ( " " ) } domain = parts [ 1 ] secret = parts [ 2 ] default : return fmt . Errorf ( " " , version ) } t . Version = version t . Domain = domain t . secret = secret return nil }
ParseFromString creates a new Token from its plaintext string
ParseFromString creates a new Token from its plaintext string