MCPcopy
hub / github.com/pocketbase/pocketbase / sendRawUserInfoRequest

Method sendRawUserInfoRequest

tools/auth/base_provider.go:176–201  ·  view source on GitHub ↗

sendRawUserInfoRequest sends the specified user info request and return its raw response body.

(req *http.Request, token *oauth2.Token)

Source from the content-addressed store, hash-verified

174
175// sendRawUserInfoRequest sends the specified user info request and return its raw response body.
176func (p *BaseProvider) sendRawUserInfoRequest(req *http.Request, token *oauth2.Token) ([]byte, error) {
177 client := p.Client(token)
178
179 res, err := client.Do(req)
180 if err != nil {
181 return nil, err
182 }
183 defer res.Body.Close()
184
185 result, err := io.ReadAll(res.Body)
186 if err != nil {
187 return nil, err
188 }
189
190 // http.Client.Get doesn't treat non 2xx responses as error
191 if res.StatusCode >= 400 {
192 return nil, fmt.Errorf(
193 "failed to fetch OAuth2 user profile via %s (%d):\n%s",
194 p.userInfoURL,
195 res.StatusCode,
196 string(result),
197 )
198 }
199
200 return result, nil
201}
202
203// oauth2Config constructs a oauth2.Config instance based on the provider settings.
204func (p *BaseProvider) oauth2Config() *oauth2.Config {

Callers 6

FetchRawUserInfoMethod · 0.95
FetchRawUserInfoMethod · 0.80
FetchRawUserInfoMethod · 0.80
FetchRawUserInfoMethod · 0.80
FetchRawUserInfoMethod · 0.80
FetchRawUserInfoMethod · 0.80

Calls 3

ClientMethod · 0.95
DoMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected