ListKeys lists the verified public keys for a user. Passing the empty string will fetch keys for the authenticated user. GitHub API docs: https://docs.github.com/rest/users/keys?apiVersion=2022-11-28#list-public-keys-for-a-user GitHub API docs: https://docs.github.com/rest/users/keys?apiVersion=20
(ctx context.Context, user string, opts *ListOptions)
| 37 | //meta:operation GET /user/keys |
| 38 | //meta:operation GET /users/{username}/keys |
| 39 | func (s *UsersService) ListKeys(ctx context.Context, user string, opts *ListOptions) ([]*Key, *Response, error) { |
| 40 | var u string |
| 41 | if user != "" { |
| 42 | u = fmt.Sprintf("users/%v/keys", user) |
| 43 | } else { |
| 44 | u = "user/keys" |
| 45 | } |
| 46 | u, err := addOptions(u, opts) |
| 47 | if err != nil { |
| 48 | return nil, nil, err |
| 49 | } |
| 50 | |
| 51 | req, err := s.client.NewRequest(ctx, "GET", u, nil) |
| 52 | if err != nil { |
| 53 | return nil, nil, err |
| 54 | } |
| 55 | |
| 56 | var keys []*Key |
| 57 | resp, err := s.client.Do(req, &keys) |
| 58 | if err != nil { |
| 59 | return nil, resp, err |
| 60 | } |
| 61 | |
| 62 | return keys, resp, nil |
| 63 | } |
| 64 | |
| 65 | // GetKey fetches a single public key. |
| 66 | // |