Skip to content

Commit 25a21d4

Browse files
nhinzedblock
authored andcommitted
Integration with DoorKeeper (#65)
Update README to show how to prefill API KEY in Swagger UI with DoorKeeper.
1 parent 1d52d6f commit 25a21d4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,22 @@ GrapeSwaggerRails.options.before_filter do |request|
143143
end
144144
```
145145

146+
#### Integration with DoorKeeper
147+
148+
Add the following code to the initializer (swagger.rb):
149+
150+
```ruby
151+
GrapeSwaggerRails.options.before_filter do |request|
152+
GrapeSwaggerRails.options.api_key_default_value = current_user.token.token
153+
end
154+
```
155+
156+
In your User model (user.rb) add:
157+
158+
```ruby
159+
has_one :token, -> { order 'created_at DESC' }, class_name: Doorkeeper::AccessToken, foreign_key: :resource_owner_id
160+
```
161+
146162
### Hiding the API or Authorization text boxes
147163

148164
If you know in advance that you would like to prevent changing the Swagger API URL, you can hide it using the following:

0 commit comments

Comments
 (0)