| 556 | } |
| 557 | |
| 558 | func (a *Auth) AccountInfo() (string, string) { |
| 559 | if a == nil { |
| 560 | return "", "" |
| 561 | } |
| 562 | switch a.AuthKind() { |
| 563 | case AuthKindOAuth: |
| 564 | if a.Metadata != nil { |
| 565 | if v, ok := a.Metadata["email"].(string); ok { |
| 566 | email := strings.TrimSpace(v) |
| 567 | if email != "" { |
| 568 | return "oauth", email |
| 569 | } |
| 570 | } |
| 571 | } |
| 572 | return "oauth", "" |
| 573 | case AuthKindAPIKey: |
| 574 | if apiKey := authAttribute(a, AttributeAPIKey); apiKey != "" { |
| 575 | return "api_key", apiKey |
| 576 | } |
| 577 | return "api_key", "" |
| 578 | default: |
| 579 | return "", "" |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | // ExpirationTime attempts to extract the credential expiration timestamp from metadata. |
| 584 | // It inspects common keys such as "expired", "expire", "expires_at", and also |