auth
auth/errors.go
Render JSON errors. Start rendering JSON errors when obtaining an access token doesn't succeed.
1 package oauth2
3 import "errors"
5 const (
6 ErrorServerError = "server_error"
7 ErrorInvalidRequest = "invalid_request"
8 ErrorAccessDenied = "access_denied"
9 ErrorInvalidClient = "invalid_client"
10 ErrorInvalidGrant = "invalid_grant"
11 ErrorUnauthorizedClient = "unauthorized_client"
12 ErrorUnsupportedGrantType = "unsupported_grant_type"
13 ErrorInvalidScope = "invalid_scope"
14 )
16 var (
17 ClientNotFoundError = errors.New("Client not found.")
18 URIMissingError = errors.New("Redirect URI missing.")
19 InvalidMethodError = errors.New("Invalid request method.")
20 InternalServerError = errors.New("Internal server error.")
21 ErrorNotAuthenticated = errors.New("Not authenticated.")
22 )
24 type URIFormatError string
26 func (err URIFormatError) Error() string {
27 return "Invalid URI format: " + string(err)
28 }
30 type InvalidClientIDError string
32 func (err InvalidClientIDError) Error() string {
33 return "Invalid client ID: " + string(err)
34 }
36 type URIMismatchError struct {
37 uri string
38 mismatch string
39 }
41 func (err URIMismatchError) Error() string {
42 return "Supplied redirect URI " + err.mismatch + " does not match the redirect in the database (" + err.uri + ")"
43 }
45 func NewURIMismatchError(uri, mismatch string) error {
46 return URIMismatchError{
47 uri: uri,
48 mismatch: mismatch,
49 }
50 }