[{"data":1,"prerenderedAt":695},["ShallowReactive",2],{"navigation_docs":3,"-http-dio":189,"-http-dio-surround":690},[4,30,65,105,120,135,164,184],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":6},"Getting started",false,"/getting-started","1.getting-started",[10,15,20,25],{"title":11,"path":12,"stem":13,"icon":14},"Introduction","/getting-started/introduction","1.getting-started/1.introduction","i-lucide-book-open",{"title":16,"path":17,"stem":18,"icon":19},"Installation","/getting-started/installation","1.getting-started/2.installation","i-lucide-download",{"title":21,"path":22,"stem":23,"icon":24},"Quick start","/getting-started/quick-start","1.getting-started/3.quick-start","i-lucide-rocket",{"title":26,"path":27,"stem":28,"icon":29},"Session Lab","/getting-started/session-lab","1.getting-started/4.session-lab","i-lucide-flask-conical",{"title":31,"icon":6,"path":32,"stem":33,"children":34,"page":6},"Concepts","/concepts","2.concepts",[35,40,45,50,55,60],{"title":36,"path":37,"stem":38,"icon":39},"How it works","/concepts/how-it-works","2.concepts/1.how-it-works","i-lucide-workflow",{"title":41,"path":42,"stem":43,"icon":44},"Sessions and tokens","/concepts/sessions-and-tokens","2.concepts/2.sessions-and-tokens","i-lucide-key-round",{"title":46,"path":47,"stem":48,"icon":49},"State and events","/concepts/state-and-events","2.concepts/3.state-and-events","i-lucide-radio",{"title":51,"path":52,"stem":53,"icon":54},"Token refresh","/concepts/token-refresh","2.concepts/4.token-refresh","i-lucide-refresh-cw",{"title":56,"path":57,"stem":58,"icon":59},"Storage","/concepts/storage","2.concepts/5.storage","i-lucide-hard-drive",{"title":61,"path":62,"stem":63,"icon":64},"Guarantees","/concepts/guarantees","2.concepts/6.guarantees","i-lucide-shield-check",{"title":66,"icon":6,"path":67,"stem":68,"children":69,"page":6},"Providers","/providers","3.providers",[70,75,80,85,90,95,100],{"title":71,"path":72,"stem":73,"icon":74},"Choosing a provider","/providers/choosing","3.providers/1.choosing","i-lucide-signpost",{"title":76,"path":77,"stem":78,"icon":79},"Credentials","/providers/credentials","3.providers/2.credentials","i-lucide-user-round-key",{"title":81,"path":82,"stem":83,"icon":84},"OAuth 2.0 and OpenID Connect","/providers/oauth2","3.providers/3.oauth2","i-lucide-shield",{"title":86,"path":87,"stem":88,"icon":89},"OAuth through your backend","/providers/backend-oauth","3.providers/4.backend-oauth","i-lucide-server",{"title":91,"path":92,"stem":93,"icon":94},"Google","/providers/google","3.providers/5.google","i-simple-icons-google",{"title":96,"path":97,"stem":98,"icon":99},"Apple","/providers/apple","3.providers/6.apple","i-simple-icons-apple",{"title":101,"path":102,"stem":103,"icon":104},"Custom providers","/providers/custom","3.providers/7.custom","i-lucide-puzzle",{"title":106,"icon":6,"path":107,"stem":108,"children":109,"page":6},"Flutter","/flutter","4.flutter",[110,115],{"title":111,"path":112,"stem":113,"icon":114},"Widgets","/flutter/widgets","4.flutter/1.widgets","i-lucide-layout-template",{"title":116,"path":117,"stem":118,"icon":119},"Routing","/flutter/routing","4.flutter/2.routing","i-lucide-route",{"title":121,"icon":6,"path":122,"stem":123,"children":124,"page":6},"HTTP","/http","5.http",[125,130],{"title":126,"path":127,"stem":128,"icon":129},"Dio","/http/dio","5.http/1.dio","i-lucide-arrow-left-right",{"title":131,"path":132,"stem":133,"icon":134},"Other HTTP clients","/http/other-clients","5.http/2.other-clients","i-lucide-plug-zap",{"title":136,"icon":6,"path":137,"stem":138,"children":139,"page":6},"Guides","/guides","6.guides",[140,145,150,155,159],{"title":141,"path":142,"stem":143,"icon":144},"Multiple accounts","/guides/multi-account","6.guides/1.multi-account","i-lucide-users",{"title":146,"path":147,"stem":148,"icon":149},"Sign-out and revocation","/guides/sign-out","6.guides/2.sign-out","i-lucide-log-out",{"title":151,"path":152,"stem":153,"icon":154},"Access policy","/guides/access-policy","6.guides/3.access-policy","i-lucide-shield-alert",{"title":156,"path":157,"stem":158,"icon":29},"Testing","/guides/testing","6.guides/4.testing",{"title":160,"path":161,"stem":162,"icon":163},"Backend requirements","/guides/backend-requirements","6.guides/5.backend-requirements","i-lucide-server-cog",{"title":165,"icon":6,"path":166,"stem":167,"children":168,"page":6},"Reference","/reference","7.reference",[169,174,179],{"title":170,"path":171,"stem":172,"icon":173},"API reference","/reference/api","7.reference/1.api","i-lucide-library",{"title":175,"path":176,"stem":177,"icon":178},"FAQ","/reference/faq","7.reference/2.faq","i-lucide-message-circle-question",{"title":180,"path":181,"stem":182,"icon":183},"Troubleshooting","/reference/troubleshooting","7.reference/3.troubleshooting","i-lucide-wrench",{"title":185,"path":186,"stem":187,"icon":188},"Changelog","/changelog","changelog","i-lucide-history",{"id":190,"title":126,"body":191,"description":683,"extension":684,"links":685,"meta":686,"navigation":687,"path":127,"seo":688,"stem":128,"__hash__":689},"docs/5.http/1.dio.md",{"type":192,"value":193,"toc":677},"minimark",[194,223,382,387,440,444,455,459,528,532,651,655,673],[195,196,201],"pre",{"className":197,"code":198,"language":199,"meta":200,"style":200},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","flutter pub add authyra_dio\n","bash","",[202,203,204],"code",{"__ignoreMap":200},[205,206,209,213,217,220],"span",{"class":207,"line":208},"line",1,[205,210,212],{"class":211},"sBMFI","flutter",[205,214,216],{"class":215},"sfazB"," pub",[205,218,219],{"class":215}," add",[205,221,222],{"class":215}," authyra_dio\n",[195,224,228],{"className":225,"code":226,"language":227,"meta":200,"style":200},"language-dart shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","final api = Dio(BaseOptions(baseUrl: 'https://api.example.com'));\napi.interceptors.add(\n  AuthyraInterceptor(\n    authyra: authyra,\n    dio: api,\n    // Never send your tokens to another host.\n    shouldAttach: (request) => request.uri.host == 'api.example.com',\n  ),\n);\n","dart",[202,229,230,268,289,297,311,324,331,366,374],{"__ignoreMap":200},[205,231,232,236,240,244,247,250,253,256,259,262,265],{"class":207,"line":208},[205,233,235],{"class":234},"spNyl","final",[205,237,239],{"class":238},"sTEyZ"," api ",[205,241,243],{"class":242},"sMK4o","=",[205,245,246],{"class":211}," Dio",[205,248,249],{"class":238},"(",[205,251,252],{"class":211},"BaseOptions",[205,254,255],{"class":238},"(baseUrl",[205,257,258],{"class":242},":",[205,260,261],{"class":215}," 'https://api.example.com'",[205,263,264],{"class":238},"))",[205,266,267],{"class":242},";\n",[205,269,271,274,277,280,282,286],{"class":207,"line":270},2,[205,272,273],{"class":238},"api",[205,275,276],{"class":242},".",[205,278,279],{"class":238},"interceptors",[205,281,276],{"class":242},[205,283,285],{"class":284},"s2Zo4","add",[205,287,288],{"class":238},"(\n",[205,290,292,295],{"class":207,"line":291},3,[205,293,294],{"class":211},"  AuthyraInterceptor",[205,296,288],{"class":238},[205,298,300,303,305,308],{"class":207,"line":299},4,[205,301,302],{"class":238},"    authyra",[205,304,258],{"class":242},[205,306,307],{"class":238}," authyra",[205,309,310],{"class":242},",\n",[205,312,314,317,319,322],{"class":207,"line":313},5,[205,315,316],{"class":238},"    dio",[205,318,258],{"class":242},[205,320,321],{"class":238}," api",[205,323,310],{"class":242},[205,325,327],{"class":207,"line":326},6,[205,328,330],{"class":329},"sHwdD","    // Never send your tokens to another host.\n",[205,332,334,337,339,342,345,348,350,353,355,358,361,364],{"class":207,"line":333},7,[205,335,336],{"class":238},"    shouldAttach",[205,338,258],{"class":242},[205,340,341],{"class":238}," (request) ",[205,343,344],{"class":242},"=>",[205,346,347],{"class":238}," request",[205,349,276],{"class":242},[205,351,352],{"class":238},"uri",[205,354,276],{"class":242},[205,356,357],{"class":238},"host ",[205,359,360],{"class":242},"==",[205,362,363],{"class":215}," 'api.example.com'",[205,365,310],{"class":242},[205,367,369,372],{"class":207,"line":368},8,[205,370,371],{"class":238},"  )",[205,373,310],{"class":242},[205,375,377,380],{"class":207,"line":376},9,[205,378,379],{"class":238},")",[205,381,267],{"class":242},[383,384,386],"h2",{"id":385},"what-it-does","What it does",[388,389,390,402,412,422],"ol",{},[391,392,393,397,398,401],"li",{},[394,395,396],"strong",{},"Before each request",", it asks ",[202,399,400],{},"authyra.accessToken()"," for a valid token. A token about to expire is refreshed first. The request records which session it was sent for.",[391,403,404,407,408,411],{},[394,405,406],{},"On a 401",", it asks for a new token for that same session, passing the rejected token, and retries the request ",[394,409,410],{},"once",". Concurrent 401s share one refresh: twenty failing requests cause one refresh call.",[391,413,414,417,418,421],{},[394,415,416],{},"When the refresh token is rejected",", the session ends (the app sees ",[202,419,420],{},"AuthSignedOut",", or the next account) and the original 401 is passed on.",[391,423,424,427,428,431,432,435,436,439],{},[394,425,426],{},"When the refresh fails for a transient reason"," and the token has expired, the request fails with a ",[202,429,430],{},"DioException"," whose ",[202,433,434],{},"error"," is a ",[202,437,438],{},"TokenRefreshException",", without being sent. The session is kept.",[441,442,443],"p",{},"Without a session, requests go out without a token.",[441,445,446,447,450,451,454],{},"It is a plain ",[202,448,449],{},"Interceptor",", not a ",[202,452,453],{},"QueuedInterceptor",": requests are not serialized behind each other, Authyra already coordinates the refresh.",[383,456,458],{"id":457},"options","Options",[460,461,462,478],"table",{},[463,464,465],"thead",{},[466,467,468,472,475],"tr",{},[469,470,471],"th",{},"Option",[469,473,474],{},"Default",[469,476,477],{},"Purpose",[479,480,481,498,513],"tbody",{},[466,482,483,489,492],{},[484,485,486],"td",{},[202,487,488],{},"shouldAttach",[484,490,491],{},"every request",[484,493,494,495,497],{},"Decide per request whether to attach the token. Use it when the same ",[202,496,126],{}," calls third-party hosts.",[466,499,500,505,510],{},[484,501,502],{},[202,503,504],{},"headerName",[484,506,507],{},[202,508,509],{},"Authorization",[484,511,512],{},"The header carrying the token.",[466,514,515,520,525],{},[484,516,517],{},[202,518,519],{},"tokenPrefix",[484,521,522],{},[202,523,524],{},"Bearer ",[484,526,527],{},"Prefix before the token.",[383,529,531],{"id":530},"per-request","Per request",[195,533,535],{"className":225,"code":534,"language":227,"meta":200,"style":200},"// A public endpoint: no token, no refresh.\nawait api.get('/health', options: Options(extra: {AuthyraInterceptor.skip: true}));\n\n// On behalf of an account that is not the active one.\nawait api.get('/me', options: Options(extra: {AuthyraInterceptor.sessionKey: key}));\n",[202,536,537,542,597,603,608],{"__ignoreMap":200},[205,538,539],{"class":207,"line":208},[205,540,541],{"class":329},"// A public endpoint: no token, no refresh.\n",[205,543,544,548,550,552,555,557,560,563,566,568,571,574,576,579,582,584,587,589,592,595],{"class":207,"line":270},[205,545,547],{"class":546},"s7zQu","await",[205,549,321],{"class":238},[205,551,276],{"class":242},[205,553,554],{"class":284},"get",[205,556,249],{"class":238},[205,558,559],{"class":215},"'/health'",[205,561,562],{"class":242},",",[205,564,565],{"class":238}," options",[205,567,258],{"class":242},[205,569,570],{"class":211}," Options",[205,572,573],{"class":238},"(extra",[205,575,258],{"class":242},[205,577,578],{"class":238}," {",[205,580,581],{"class":211},"AuthyraInterceptor",[205,583,276],{"class":242},[205,585,586],{"class":238},"skip",[205,588,258],{"class":242},[205,590,591],{"class":242}," true",[205,593,594],{"class":238},"}))",[205,596,267],{"class":242},[205,598,599],{"class":207,"line":291},[205,600,602],{"emptyLinePlaceholder":601},true,"\n",[205,604,605],{"class":207,"line":299},[205,606,607],{"class":329},"// On behalf of an account that is not the active one.\n",[205,609,610,612,614,616,618,620,623,625,627,629,631,633,635,637,639,641,644,646,649],{"class":207,"line":313},[205,611,547],{"class":546},[205,613,321],{"class":238},[205,615,276],{"class":242},[205,617,554],{"class":284},[205,619,249],{"class":238},[205,621,622],{"class":215},"'/me'",[205,624,562],{"class":242},[205,626,565],{"class":238},[205,628,258],{"class":242},[205,630,570],{"class":211},[205,632,573],{"class":238},[205,634,258],{"class":242},[205,636,578],{"class":238},[205,638,581],{"class":211},[205,640,276],{"class":242},[205,642,643],{"class":238},"sessionKey",[205,645,258],{"class":242},[205,647,648],{"class":238}," key}))",[205,650,267],{"class":242},[383,652,654],{"id":653},"use-a-separate-client-for-auth-calls","Use a separate client for auth calls",[441,656,657,658,660,661,664,665,668,669,276],{},"The ",[202,659,126],{}," your provider uses for ",[202,662,663],{},"/auth/login"," and ",[202,666,667],{},"/auth/refresh"," must not carry this interceptor: a refresh call that triggers a refresh cannot finish. Keep two instances, as in the ",[670,671,672],"a",{"href":22},"quick start",[674,675,676],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}",{"title":200,"searchDepth":270,"depth":270,"links":678},[679,680,681,682],{"id":385,"depth":270,"text":386},{"id":457,"depth":270,"text":458},{"id":530,"depth":270,"text":531},{"id":653,"depth":270,"text":654},"Attach tokens to requests and recover from 401 with a single shared refresh.","md",null,{},{"icon":129},{"title":126,"description":683},"vkiBBDBueQCCMc0aXCY-maZZcS15sGy6kncDnoHlmVg",[691,693],{"title":116,"path":117,"stem":118,"description":692,"icon":119,"children":-1},"Redirect between the splash, sign-in and app routes with any router.",{"title":131,"path":132,"stem":133,"description":694,"icon":134,"children":-1},"Use Authyra with package:http, Chopper, gRPC or anything else.",1794303130035]