You've already forked pocketbase
mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-07-15 10:14:15 +02:00
improve error reporting on OAuth2 user profile fetch
This commit is contained in:
@ -3,6 +3,7 @@ package auth
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@ -120,6 +121,16 @@ func (p *baseProvider) FetchRawUserData(token *oauth2.Token, result any) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// http.Client.Get doesn't treat non 2xx responses as error
|
||||||
|
if response.StatusCode >= 400 {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"Failed to fetch OAuth2 user profile via %s (%d):\n%s",
|
||||||
|
p.userApiUrl,
|
||||||
|
response.StatusCode,
|
||||||
|
string(content),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return json.Unmarshal(content, &result)
|
return json.Unmarshal(content, &result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user