package server import ( "somehole.com/service/oauth2/session" "somehole.com/service/router" ) type TokenRequestBuilder struct { router.DefaultRequestBuilder values struct { router.Values ResponseType string `form:"response_type"` ClientId string `form:"client_id"` Code session.Code `form:"code"` } } func (*TokenRequestBuilder) Prototype() router.PrototypeRequestBuilder { rb := CallbackRequestBuilder{} rb.DefaultRequestBuilder = router.NewDefaultRequestBuilder(). SetErrorHandler(&ErrorHandler{}). SetValues(&rb.values.Values, &rb.values). SetDefaults() return rb } func (rb TokenRequestBuilder) RequestBuilder() router.RequestBuilder { return &rb } type TokenResponse struct { *router.DefaultResponse Body struct { router.Body VerificationUri string `json:"verification_uri"` UserCode session.Code `json:"user_code"` DeviceCode session.Code `json:"device_code"` Interval int `json:"interval"` ExpiresIn int `json:"expires_in"` } } func (*TokenResponse) Prototype() router.PrototypeResponse { r := TokenResponse{} r.DefaultResponse = router.NewDefaultResponse(). SetBody(&r.Body.Body, &r.Body). SetDefaults() return r } func (r TokenResponse) Response() router.Response { return &r } type UnimplementedTokenServer struct { *ErrorHandler } func (UnimplementedTokenServer) mustEmbedUnimplementedTokenServer() {} func (u UnimplementedTokenServer) Token(req *TokenRequestBuilder) (res *TokenResponse, errRes router.ErrorResponse) { errRes = u.ErrorResponse(router.DefaultErrorNotImplemented) return } type TokenServer interface { mustEmbedUnimplementedTokenServer() Token(req *TokenRequestBuilder) (res *TokenResponse, errRes router.ErrorResponse) }