@@ -3,8 +3,7 @@ package scalaoauth2.provider
33import play .api .libs .json ._
44import play .api .mvc ._
55
6- import scala .concurrent .ExecutionContext .Implicits .global
7- import scala .concurrent .Future
6+ import scala .concurrent .{ExecutionContext , Future }
87import scala .language .implicitConversions
98
109/**
@@ -113,11 +112,13 @@ trait OAuth2Provider extends OAuth2BaseProvider {
113112 *
114113 * @param handler Implemented AuthorizationHandler for register access token to your system.
115114 * @param request Playframework is provided HTTP request interface.
115+ * @param ctx This context is used by TokenEndPoint.
116116 * @tparam A play.api.mvc.Request has type.
117+ * @tparam U set the type in AuthorizationHandler.
117118 * @return Request is successful then return JSON to client in OAuth 2.0 format.
118119 * Request is failed then return BadRequest or Unauthorized status to client with cause into the JSON.
119120 */
120- def issueAccessToken [A , U ](handler : AuthorizationHandler [U ])(implicit request : Request [A ]): Future [Result ] = {
121+ def issueAccessToken [A , U ](handler : AuthorizationHandler [U ])(implicit request : Request [A ], ctx : ExecutionContext ): Future [Result ] = {
121122 tokenEndpoint.handleRequest(request, handler).map {
122123 case Left (e) if e.statusCode == 400 => BadRequest (responseOAuthErrorJson(e)).withHeaders(responseOAuthErrorHeader(e))
123124 case Left (e) if e.statusCode == 401 => Unauthorized (responseOAuthErrorJson(e)).withHeaders(responseOAuthErrorHeader(e))
@@ -131,11 +132,13 @@ trait OAuth2Provider extends OAuth2BaseProvider {
131132 * @param handler Implemented ProtectedResourceHandler for authenticate to your system.
132133 * @param callback Callback is called when authentication is successful.
133134 * @param request Playframework is provided HTTP request interface.
135+ * @param ctx This contxt is used by ProtectedResource.
134136 * @tparam A play.api.mvc.Request has type.
137+ * @tparam U set the type in AuthorizationHandler.
135138 * @return Authentication is successful then the response use your API result.
136139 * Authentication is failed then return BadRequest or Unauthorized status to client with cause into the JSON.
137140 */
138- def authorize [A , U ](handler : ProtectedResourceHandler [U ])(callback : AuthInfo [U ] => Future [Result ])(implicit request : Request [A ]): Future [Result ] = {
141+ def authorize [A , U ](handler : ProtectedResourceHandler [U ])(callback : AuthInfo [U ] => Future [Result ])(implicit request : Request [A ], ctx : ExecutionContext ): Future [Result ] = {
139142 protectedResource.handleRequest(request, handler).flatMap {
140143 case Left (e) if e.statusCode == 400 => Future .successful(BadRequest .withHeaders(responseOAuthErrorHeader(e)))
141144 case Left (e) if e.statusCode == 401 => Future .successful(Unauthorized .withHeaders(responseOAuthErrorHeader(e)))
0 commit comments