Skip to content

Commit 0506ed1

Browse files
committed
add documentation about using action composition
1 parent c77baf0 commit 0506ed1

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ If you'd like to change the OAuth workflow, modify handleRequest methods of Toke
153153
### Customizing Grant Handlers
154154

155155
If you want to change which grant types are supported or to use a customized handler for a grant type, you can
156-
override the ```handlers``` map in a customized ```TokenEndpoint``` trait since version 0.10.0. Here's an example of a customized
157-
```TokenEndpoint``` that 1) only supports the ```password``` grant type, and 2) customizes the ``password``` grant
156+
override the ```handlers``` map in a customized ```TokenEndpoint``` trait. Here's an example of a customized
157+
```TokenEndpoint``` that 1) only supports the ```password``` grant type, and 2) customizes the ```password``` grant
158158
type handler to not require client credentials:
159159

160160
```scala
@@ -169,6 +169,24 @@ class MyTokenEndpoint extends TokenEndpoint {
169169
}
170170
```
171171

172+
### Using Action composition
173+
174+
You can write more easily authorize action by using Action composition.
175+
176+
Playframework's documentation is [here](https://www.playframework.com/documentation/2.3.x/ScalaActionsComposition).
177+
178+
```scala
179+
object MyController extends Controller {
180+
181+
import scalaoauth2.provider.OAuth2ProviderActionBuilders._
182+
183+
def list = AuthorizedAction(new MyDataHandler()) { request =>
184+
val user = request.authInfo.user // User is defined on your system
185+
// access resource for the user
186+
}
187+
}
188+
```
189+
172190
## Examples
173191

174192
### Playframework 2.3

0 commit comments

Comments
 (0)