PostOAuth2ProviderApp adds an application that can authenticate using Coder as an OAuth2 provider.
(ctx context.Context, app PostOAuth2ProviderAppRequest)
| 83 | // PostOAuth2ProviderApp adds an application that can authenticate using Coder |
| 84 | // as an OAuth2 provider. |
| 85 | func (c *Client) PostOAuth2ProviderApp(ctx context.Context, app PostOAuth2ProviderAppRequest) (OAuth2ProviderApp, error) { |
| 86 | res, err := c.Request(ctx, http.MethodPost, "/api/v2/oauth2-provider/apps", app) |
| 87 | if err != nil { |
| 88 | return OAuth2ProviderApp{}, err |
| 89 | } |
| 90 | defer res.Body.Close() |
| 91 | if res.StatusCode != http.StatusCreated { |
| 92 | return OAuth2ProviderApp{}, ReadBodyAsError(res) |
| 93 | } |
| 94 | var resp OAuth2ProviderApp |
| 95 | return resp, json.NewDecoder(res.Body).Decode(&resp) |
| 96 | } |
| 97 | |
| 98 | type PutOAuth2ProviderAppRequest struct { |
| 99 | Name string `json:"name" validate:"required,oauth2_app_name"` |