File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,29 @@ class in `config/application.rb`.
187187config.railties_order = [RpiAuth ::Engine , :main_app , :all ]
188188```
189189
190+ ### Obtaining an access token for user
191+
192+ This optional behaviour is useful if your Rails app (which is using this gem)
193+ needs to use a RPF API which required authentication via an OAuth2 access
194+ token.
195+
196+ Include the ` RpiAuth::Models::WithTokens ` concern (which depends on the
197+ ` RpiAuth::Models::Authenticatable ` concern) into your user model in order to
198+ add ` access_token ` , ` refresh_token ` & ` expires_at ` attributes. These methods
199+ are automatically populated by ` RpiAuth::AuthController#callback ` via the
200+ ` RpiAuth::Models::WithTokens.from_omniauth ` method.
201+
202+ This also relies on the following:
203+ - ` RpiAuth.configuration.scope ` including the "offline" scope in the Rails app
204+ which is using the ` rpi_auth ` gem.
205+ - In the ` profile ` app ` hydra_client ` config for the Rails app, ` grant_types `
206+ must include "refresh_token" and ` scope ` must include "offline".
207+
208+ Include the ` RpiAuth::Controllers::AutoRefreshingToken ` concern (which depends
209+ on the ` RpiAuth::Controllers::CurrentUser ` concern) into your controller so
210+ that when the user's access token expires, a new one is obtained using the
211+ user's refresh token.
212+
190213## Test helpers and routes
191214
192215There are some standardised test helpers in ` RpiAuth::SpecHelpers ` that can be used when testing.
You can’t perform that action at this time.
0 commit comments