MCPcopy Index your code
hub / github.com/coder/coder / ExternalAuth

Method ExternalAuth

codersdk/agentsdk/agentsdk.go:732–762  ·  view source on GitHub ↗

ExternalAuth submits a URL or provider ID to fetch an access token for. nolint:revive

(ctx context.Context, req ExternalAuthRequest)

Source from the content-addressed store, hash-verified

730// ExternalAuth submits a URL or provider ID to fetch an access token for.
731// nolint:revive
732func (c *Client) ExternalAuth(ctx context.Context, req ExternalAuthRequest) (ExternalAuthResponse, error) {
733 q := url.Values{
734 "id": []string{req.ID},
735 "match": []string{req.Match},
736 }
737 if req.Listen {
738 q.Set("listen", "true")
739 }
740 if req.GitBranch != "" {
741 q.Set("git_branch", req.GitBranch)
742 }
743 if req.GitRemoteOrigin != "" {
744 q.Set("git_remote_origin", req.GitRemoteOrigin)
745 }
746 if req.ChatID != "" {
747 q.Set("chat_id", req.ChatID)
748 }
749 reqURL := "/api/v2/workspaceagents/me/external-auth?" + q.Encode()
750 res, err := c.SDK.Request(ctx, http.MethodGet, reqURL, nil)
751 if err != nil {
752 return ExternalAuthResponse{}, xerrors.Errorf("execute request: %w", err)
753 }
754 defer res.Body.Close()
755
756 if res.StatusCode != http.StatusOK {
757 return ExternalAuthResponse{}, codersdk.ReadBodyAsError(res)
758 }
759
760 var authResp ExternalAuthResponse
761 return authResp, json.NewDecoder(res.Body).Decode(&authResp)
762}
763
764// LogsNotifyChannel returns the channel name responsible for notifying
765// of new logs.

Callers 5

TestExternalAuthCallbackFunction · 0.80
gitAskpassFunction · 0.80
externalAuthAccessTokenFunction · 0.80

Calls 6

ReadBodyAsErrorFunction · 0.92
EncodeMethod · 0.80
SetMethod · 0.65
CloseMethod · 0.65
RequestMethod · 0.45
ErrorfMethod · 0.45

Tested by 3

TestExternalAuthCallbackFunction · 0.64