Skip to content

Commit 6b10686

Browse files
authored
Merge pull request #105 from kshaaban-/patch-1
Update README.md clarifying null request options #92
2 parents c9aa437 + 74bd007 commit 6b10686

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,19 @@ angular
210210
});
211211
```
212212
213+
**Note: If your `tokenGetter` relies on request `options`.** Be mindful that `checkAuthOnRefresh()` will pass `null` as `options` since the call happens in the run phase of the angular lifecycle and no requests are fired through the angular app. So you need to check if `options` isn't null in your `tokenGetter`:
214+
215+
```js
216+
...
217+
tokenGetter: ['options', function (options) {
218+
if (options && options.url.substr(options.url.length - 5) == '.html') {
219+
return null;
220+
}
221+
return localStorage.getItem('id_token');
222+
}],
223+
...
224+
```
225+
213226
### Redirecting the User On Unauthorized Requests
214227
215228
When the user's JWT expires and they attempt a call to a secured endpoint, a 401 - Unauthorized response will be returned. In these cases you will likely want to redirect the user back to the page/state used for authentication so they can log in again. This can be done with the `redirectWhenUnauthenticated` method in the application's `run` block.

0 commit comments

Comments
 (0)