Skip to content

Commit a99d65c

Browse files
committed
Add document about async provider
1 parent c83c314 commit a99d65c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,23 @@ If you'd like to use this with Playframework, add "play2-oauth2-provider" to lib
2222

2323
```scala
2424
libraryDependencies ++= Seq(
25-
"com.nulab-inc" %% "play2-oauth2-provider" % "0.5.1"
25+
"com.nulab-inc" %% "play2-oauth2-provider" % "0.6.0"
2626
)
2727
```
2828

2929
Otherwise, add "scala-oauth2-core" instead. In this case, you need to implement your own OAuth provider working with web framework you use.
30+
3031
```scala
3132
libraryDependencies ++= Seq(
32-
"com.nulab-inc" %% "scala-oauth2-core" % "0.5.1"
33+
"com.nulab-inc" %% "scala-oauth2-core" % "0.6.0"
3334
)
3435
```
3536

3637
## How to use
3738

3839
### Implement DataHandler
3940

40-
Whether you use Playframework or not, you have to implement DataHandler trait and make it work with your own "User" class that may be already defined in your application.
41+
Whether you use Playframework or not, you have to implement ```DataHandler``` trait and make it work with your own ```User``` class that may be already defined in your application.
4142

4243
```scala
4344
case class User(id: Long, name: String, hashedPassword: String)
@@ -67,7 +68,7 @@ class MyDataHandler extends DataHandler[User] {
6768
}
6869
```
6970

70-
For more details, refer to Scaladoc of DataHandler.
71+
For more details, refer to Scaladoc of ```DataHandler```.
7172

7273
### Work with Playframework
7374

@@ -77,7 +78,9 @@ You should follow three steps below to work with Playframework.
7778
* Assign a route to the controller
7879
* Access to an authorized resource
7980

80-
First, define your own controller with mixining OAuth2Provider trait provided by this library to issue access token.
81+
First, define your own controller with mixining ```OAuth2Provider``` trait provided by this library to issue access token.
82+
Asynchronous result is used in your controller then you can use ```OAuth2AsyncProvider```, which supports returning ```Future[SimpleResult]```.
83+
8184
```scala
8285
import scalaoauth2.provider._
8386
object OAuth2Controller extends Controller with OAuth2Provider {
@@ -88,11 +91,13 @@ object OAuth2Controller extends Controller with OAuth2Provider {
8891
```
8992

9093
Then, assign a route to the controller that OAuth clients will access to.
94+
9195
```
9296
POST /oauth2/access_token controllers.OAuth2Controller.accessToken
9397
```
9498

9599
Finally, you can access to an authorized resource like this:
100+
96101
```scala
97102
import scalaoauth2.provider._
98103
object MyController extends Controller with OAuth2Provider {
@@ -105,4 +110,4 @@ object MyController extends Controller with OAuth2Provider {
105110
}
106111
```
107112

108-
If you'd like to change the OAuth workflow, modify handleRequest methods of TokenEndPoint and ProtectedResource traits.
113+
If you'd like to change the OAuth workflow, modify handleRequest methods of TokenEndPoint and ```ProtectedResource``` traits.

0 commit comments

Comments
 (0)