|
| 1 | +<!doctype html> |
| 2 | +<html class="no-js" lang=""> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta http-equiv="x-ua-compatible" content="ie=edge"> |
| 6 | + <title>angular-oauth2-oidc</title> |
| 7 | + <meta name="description" content=""> |
| 8 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 9 | + |
| 10 | + <link rel="icon" type="image/x-icon" href="../images/favicon.ico"> |
| 11 | + <link rel="stylesheet" href="../styles/style.css"> |
| 12 | + <link rel="stylesheet" href="../styles/dark.css" media="(prefers-color-scheme: dark)"> |
| 13 | + </head> |
| 14 | + <body> |
| 15 | + |
| 16 | + <div class="navbar navbar-default navbar-fixed-top visible-xs"> |
| 17 | + <a href="../" class="navbar-brand">angular-oauth2-oidc</a> |
| 18 | + <button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button> |
| 19 | + </div> |
| 20 | + |
| 21 | + <div class="xs-menu menu" id="mobile-menu"> |
| 22 | + <div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu> |
| 23 | + </div> |
| 24 | + |
| 25 | + <div class="container-fluid main"> |
| 26 | + <div class="row main"> |
| 27 | + <div class="hidden-xs menu"> |
| 28 | + <compodoc-menu mode="normal"></compodoc-menu> |
| 29 | + </div> |
| 30 | + <!-- START CONTENT --> |
| 31 | + <div class="content additional-page"> |
| 32 | + <div class="content-data"> |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +<h1 id="refreshing-a-token-using-code-flow-not-implicit-flow">Refreshing a Token using Code Flow (not Implicit Flow!)</h1> |
| 53 | +<p>When using code flow, you can get an <code>refresh_token</code>. While the original standard DOES NOT allow this for SPAs, the mentioned <a href="https://tools.ietf.org/html/draft-ietf-oauth-security-topics-13">OAuth 2.0 Security Best Current Practice</a> document proposes to ease this limitation. However, it specifies a list of requirements one should take care about before using <code>refresh_tokens</code>. Please make sure you respect those requirements.</p> |
| 54 | +<p>Please also note, that you have to request the <code>offline_access</code> scope to get a refresh token.</p> |
| 55 | +<p>To refresh your token, just call the <code>refreshToken</code> method:</p> |
| 56 | +<div><pre class="line-numbers"><code class="language-typescript">this.oauthService.refreshToken();</code></pre></div><h2 id="automatically-refreshing-a-token-when-before-it-expires-code-flow-and-implicit-flow">Automatically refreshing a token when/ before it expires (Code Flow and Implicit Flow)</h2> |
| 57 | +<p>To automatically refresh a token when/ some time before it expires, just call the following method after configuring the <code>OAuthService</code>:</p> |
| 58 | +<div><pre class="line-numbers"><code class="language-TypeScript">this.oauthService.setupAutomaticSilentRefresh();</code></pre></div><p>By default, this event is fired after 75% of the token's life time is over. You can adjust this factor by setting the property <code>timeoutFactor</code> to a value between 0 and 1. For instance, 0.5 means, that the event is fired after half of the life time is over and 0.33 triggers the event after a third.</p> |
| 59 | + |
| 60 | + </div><div class="search-results"> |
| 61 | + <div class="has-results"> |
| 62 | + <h1 class="search-results-title"><span class='search-results-count'></span> result-matching "<span class='search-query'></span>"</h1> |
| 63 | + <ul class="search-results-list"></ul> |
| 64 | + </div> |
| 65 | + <div class="no-results"> |
| 66 | + <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1> |
| 67 | + </div> |
| 68 | +</div> |
| 69 | +</div> |
| 70 | + <!-- END CONTENT --> |
| 71 | + </div> |
| 72 | + </div> |
| 73 | + |
| 74 | + <script> |
| 75 | + var COMPODOC_CURRENT_PAGE_DEPTH = 1; |
| 76 | + var COMPODOC_CURRENT_PAGE_CONTEXT = 'additional-page'; |
| 77 | + var COMPODOC_CURRENT_PAGE_URL = 'token-refresh.html'; |
| 78 | + var MAX_SEARCH_RESULTS = 15; |
| 79 | + </script> |
| 80 | + |
| 81 | + <script src="../js/libs/custom-elements.min.js"></script> |
| 82 | + <script src="../js/libs/lit-html.js"></script> |
| 83 | + |
| 84 | + <script type="module" src="../js/menu-wc.js" defer></script> |
| 85 | + <script nomodule src="../js/menu-wc_es5.js" defer></script> |
| 86 | + |
| 87 | + <script src="../js/libs/bootstrap-native.js"></script> |
| 88 | + |
| 89 | + <script src="../js/libs/es6-shim.min.js"></script> |
| 90 | + <script src="../js/libs/EventDispatcher.js"></script> |
| 91 | + <script src="../js/libs/promise.min.js"></script> |
| 92 | + <script src="../js/libs/zepto.min.js"></script> |
| 93 | + |
| 94 | + <script src="../js/compodoc.js"></script> |
| 95 | + |
| 96 | + <script src="../js/tabs.js"></script> |
| 97 | + <script src="../js/menu.js"></script> |
| 98 | + <script src="../js/libs/clipboard.min.js"></script> |
| 99 | + <script src="../js/libs/prism.js"></script> |
| 100 | + <script src="../js/sourceCode.js"></script> |
| 101 | + <script src="../js/search/search.js"></script> |
| 102 | + <script src="../js/search/lunr.min.js"></script> |
| 103 | + <script src="../js/search/search-lunr.js"></script> |
| 104 | + <script src="../js/search/search_index.js"></script> |
| 105 | + <script src="../js/lazy-load-graphs.js"></script> |
| 106 | + |
| 107 | + |
| 108 | + </body> |
| 109 | +</html> |
0 commit comments