Validate validates the Teams configuration by attempting to get a token and look up a user.
(ctx context.Context, tenantID, clientID, clientSecret, email string)
| 601 | |
| 602 | // Validate validates the Teams configuration by attempting to get a token and look up a user. |
| 603 | func Validate(ctx context.Context, tenantID, clientID, clientSecret, email string) error { |
| 604 | // Trim whitespace from all inputs to prevent copy-paste issues. |
| 605 | tenantID = strings.TrimSpace(tenantID) |
| 606 | clientID = strings.TrimSpace(clientID) |
| 607 | clientSecret = strings.TrimSpace(clientSecret) |
| 608 | email = strings.TrimSpace(email) |
| 609 | |
| 610 | p := newProvider(tenantID, clientID, clientSecret) |
| 611 | |
| 612 | if err := p.refreshGraphToken(ctx); err != nil { |
| 613 | return errors.Wrapf(err, "failed to get Graph API token") |
| 614 | } |
| 615 | |
| 616 | _, err := p.getIDByEmail(ctx, []string{email}) |
| 617 | if err != nil { |
| 618 | return errors.Wrapf(err, "failed to look up user %s", email) |
| 619 | } |
| 620 | |
| 621 | return nil |
| 622 | } |
no test coverage detected