OAuth2ProviderApps returns the applications configured to authenticate using Coder as an OAuth2 provider.
(ctx context.Context, filter OAuth2ProviderAppFilter)
| 40 | // OAuth2ProviderApps returns the applications configured to authenticate using |
| 41 | // Coder as an OAuth2 provider. |
| 42 | func (c *Client) OAuth2ProviderApps(ctx context.Context, filter OAuth2ProviderAppFilter) ([]OAuth2ProviderApp, error) { |
| 43 | res, err := c.Request(ctx, http.MethodGet, "/api/v2/oauth2-provider/apps", nil, |
| 44 | func(r *http.Request) { |
| 45 | if filter.UserID != uuid.Nil { |
| 46 | q := r.URL.Query() |
| 47 | q.Set("user_id", filter.UserID.String()) |
| 48 | r.URL.RawQuery = q.Encode() |
| 49 | } |
| 50 | }) |
| 51 | if err != nil { |
| 52 | return []OAuth2ProviderApp{}, err |
| 53 | } |
| 54 | defer res.Body.Close() |
| 55 | if res.StatusCode != http.StatusOK { |
| 56 | return []OAuth2ProviderApp{}, ReadBodyAsError(res) |
| 57 | } |
| 58 | var apps []OAuth2ProviderApp |
| 59 | return apps, json.NewDecoder(res.Body).Decode(&apps) |
| 60 | } |
| 61 | |
| 62 | // OAuth2ProviderApp returns an application configured to authenticate using |
| 63 | // Coder as an OAuth2 provider. |