[{"data":1,"prerenderedAt":674},["ShallowReactive",2],{"navigation_docs":3,"-providers-backend-oauth":189,"-providers-backend-oauth-surround":669},[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":86,"body":191,"description":662,"extension":663,"links":664,"meta":665,"navigation":666,"path":87,"seo":667,"stem":88,"__hash__":668},"docs/3.providers/4.backend-oauth.md",{"type":192,"value":193,"toc":657},"minimark",[194,198,220,235,240,426,455,458,508,518,522,626,642,646,649,653],[195,196,197],"p",{},"Some providers cannot be used directly from an app:",[199,200,201,214],"ul",{},[202,203,204,208,209,213],"li",{},[205,206,207],"strong",{},"The token exchange needs a client secret."," GitHub requires ",[210,211,212],"code",{},"client_secret"," on its token endpoint, even with PKCE. A secret shipped in an app is public.",[202,215,216,219],{},[205,217,218],{},"Their tokens are not yours."," A GitHub access token lets you call GitHub, not your API. It carries no OpenID Connect ID token, and by default it never expires.",[195,221,222,223,226,227,230,231,234],{},"The answer is to let your backend run the OAuth flow and hand the app ",[205,224,225],{},"your own session tokens",". ",[210,228,229],{},"BackendOAuthProvider"," (in ",[210,232,233],{},"authyra_flutter",") is the app side of that contract.",[236,237,239],"h2",{"id":238},"github-end-to-end","GitHub, end to end",[241,242,247],"pre",{"className":243,"code":244,"language":245,"meta":246,"style":246},"language-dart shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","BackendOAuthProvider(\n  id: 'github',\n  config: BackendOAuthConfig(\n    startUrl: Uri.parse('https://api.example.com/auth/github/start'),\n    exchangeEndpoint: Uri.parse('https://api.example.com/auth/exchange'),\n    refreshEndpoint: Uri.parse('https://api.example.com/auth/refresh'),\n    signOutEndpoint: Uri.parse('https://api.example.com/auth/sign-out'),\n    redirectUri: Uri.parse('com.example.app:/auth-callback'),\n  ),\n)\n","dart","",[210,248,249,261,278,291,320,343,366,389,412,420],{"__ignoreMap":246},[250,251,254,257],"span",{"class":252,"line":253},"line",1,[250,255,229],{"class":256},"sBMFI",[250,258,260],{"class":259},"sTEyZ","(\n",[250,262,264,267,271,275],{"class":252,"line":263},2,[250,265,266],{"class":259},"  id",[250,268,270],{"class":269},"sMK4o",":",[250,272,274],{"class":273},"sfazB"," 'github'",[250,276,277],{"class":269},",\n",[250,279,281,284,286,289],{"class":252,"line":280},3,[250,282,283],{"class":259},"  config",[250,285,270],{"class":269},[250,287,288],{"class":256}," BackendOAuthConfig",[250,290,260],{"class":259},[250,292,294,297,299,302,305,309,312,315,318],{"class":252,"line":293},4,[250,295,296],{"class":259},"    startUrl",[250,298,270],{"class":269},[250,300,301],{"class":256}," Uri",[250,303,304],{"class":269},".",[250,306,308],{"class":307},"s2Zo4","parse",[250,310,311],{"class":259},"(",[250,313,314],{"class":273},"'https://api.example.com/auth/github/start'",[250,316,317],{"class":259},")",[250,319,277],{"class":269},[250,321,323,326,328,330,332,334,336,339,341],{"class":252,"line":322},5,[250,324,325],{"class":259},"    exchangeEndpoint",[250,327,270],{"class":269},[250,329,301],{"class":256},[250,331,304],{"class":269},[250,333,308],{"class":307},[250,335,311],{"class":259},[250,337,338],{"class":273},"'https://api.example.com/auth/exchange'",[250,340,317],{"class":259},[250,342,277],{"class":269},[250,344,346,349,351,353,355,357,359,362,364],{"class":252,"line":345},6,[250,347,348],{"class":259},"    refreshEndpoint",[250,350,270],{"class":269},[250,352,301],{"class":256},[250,354,304],{"class":269},[250,356,308],{"class":307},[250,358,311],{"class":259},[250,360,361],{"class":273},"'https://api.example.com/auth/refresh'",[250,363,317],{"class":259},[250,365,277],{"class":269},[250,367,369,372,374,376,378,380,382,385,387],{"class":252,"line":368},7,[250,370,371],{"class":259},"    signOutEndpoint",[250,373,270],{"class":269},[250,375,301],{"class":256},[250,377,304],{"class":269},[250,379,308],{"class":307},[250,381,311],{"class":259},[250,383,384],{"class":273},"'https://api.example.com/auth/sign-out'",[250,386,317],{"class":259},[250,388,277],{"class":269},[250,390,392,395,397,399,401,403,405,408,410],{"class":252,"line":391},8,[250,393,394],{"class":259},"    redirectUri",[250,396,270],{"class":269},[250,398,301],{"class":256},[250,400,304],{"class":269},[250,402,308],{"class":307},[250,404,311],{"class":259},[250,406,407],{"class":273},"'com.example.app:/auth-callback'",[250,409,317],{"class":259},[250,411,277],{"class":269},[250,413,415,418],{"class":252,"line":414},9,[250,416,417],{"class":259},"  )",[250,419,277],{"class":269},[250,421,423],{"class":252,"line":422},10,[250,424,425],{"class":259},")\n",[241,427,429],{"className":243,"code":428,"language":245,"meta":246,"style":246},"await authyra.signIn('github');\n",[210,430,431],{"__ignoreMap":246},[250,432,433,437,440,442,445,447,450,452],{"class":252,"line":253},[250,434,436],{"class":435},"s7zQu","await",[250,438,439],{"class":259}," authyra",[250,441,304],{"class":269},[250,443,444],{"class":307},"signIn",[250,446,311],{"class":259},[250,448,449],{"class":273},"'github'",[250,451,317],{"class":259},[250,453,454],{"class":269},";\n",[195,456,457],{},"What happens:",[459,460,461,468,479,489,496,505],"ol",{},[202,462,463,464,467],{},"The app opens ",[210,465,466],{},"startUrl?redirect_uri=...&state=..."," in a secure browser session.",[202,469,470,471,474,475,478],{},"Your backend checks ",[210,472,473],{},"redirect_uri"," against an allowlist, remembers ",[210,476,477],{},"state",", and redirects to GitHub's consent page.",[202,480,481,482,484,485,488],{},"GitHub calls your backend back. The backend exchanges the code with its ",[210,483,212],{},", finds or creates the user, and creates a ",[205,486,487],{},"short-lived, single-use code"," of its own.",[202,490,491,492,495],{},"The backend redirects to ",[210,493,494],{},"redirect_uri?code=\u003Cone-time code>&state=\u003Csame state>",". Tokens never travel in a URL.",[202,497,498,499,501,502,304],{},"The app checks ",[210,500,477],{},", then posts the code to ",[210,503,504],{},"exchangeEndpoint",[202,506,507],{},"Your backend answers with the user and your session tokens.",[195,509,510,511,514,515,304],{},"From then on, the session is an ordinary session of your API: refreshed through ",[210,512,513],{},"refreshEndpoint",", revoked through ",[210,516,517],{},"signOutEndpoint",[236,519,521],{"id":520},"the-contract-your-backend-implements","The contract your backend implements",[523,524,525,541],"table",{},[526,527,528],"thead",{},[529,530,531,535,538],"tr",{},[532,533,534],"th",{},"Endpoint",[532,536,537],{},"Request",[532,539,540],{},"Response",[542,543,544,560,578,594,613],"tbody",{},[529,545,546,552,557],{},[547,548,549],"td",{},[210,550,551],{},"startUrl",[547,553,554],{},[210,555,556],{},"GET ?redirect_uri=...&state=...",[547,558,559],{},"A redirect to the provider.",[529,561,562,565,568],{},[547,563,564],{},"Provider callback",[547,566,567],{},"(between your backend and the provider)",[547,569,570,571,574,575,304],{},"A redirect to ",[210,572,573],{},"redirect_uri?code=...&state=...",", or ",[210,576,577],{},"?error=...&state=...",[529,579,580,584,589],{},[547,581,582],{},[210,583,504],{},[547,585,586],{},[210,587,588],{},"POST {\"code\": \"...\"}",[547,590,591],{},[210,592,593],{},"{\"user\": {\"id\": \"...\", \"email\": \"...\"}, \"access_token\": \"...\", \"refresh_token\": \"...\", \"expires_in\": 900}",[529,595,596,601,606],{},[547,597,598,600],{},[210,599,513],{}," (optional)",[547,602,603],{},[210,604,605],{},"POST {\"refresh_token\": \"...\"}",[547,607,608,609,612],{},"A token response like the one above without ",[210,610,611],{},"user",", or 401 when the token is rejected.",[529,614,615,619,623],{},[547,616,617,600],{},[210,618,517],{},[547,620,621],{},[210,622,605],{},[547,624,625],{},"A 2xx with an empty or JSON-object body. A failure is logged; the local sign-out happens anyway.",[195,627,628,631,632,635,636,638,639,304],{},[210,629,630],{},"headers"," adds headers to every call (an API key, an app version), and ",[210,633,634],{},"userFromJson"," maps the ",[210,637,611],{}," object to an ",[210,640,641],{},"AuthUser",[236,643,645],{"id":644},"other-providers","Other providers",[195,647,648],{},"The same pattern fits GitLab, Discord, Slack, Bitbucket, LinkedIn, or several of them behind one backend route per provider. Your backend can also link the identities to one account in your database.",[650,651,652],"note",{},"GitHub's device flow needs no client secret, but it is designed for CLIs and TVs, and it still yields a GitHub token rather than a session of your API.",[654,655,656],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}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 .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}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 .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":246,"searchDepth":263,"depth":263,"links":658},[659,660,661],{"id":238,"depth":263,"text":239},{"id":520,"depth":263,"text":521},{"id":644,"depth":263,"text":645},"Social logins such as GitHub, whose client secret must stay on a server and whose tokens your API does not accept.","md",null,{},{"icon":89},{"title":86,"description":662},"p3SLTDE1O9ZKZtwChBwdfJRd0NQgCBtbEGFEtyMYzxk",[670,672],{"title":81,"path":82,"stem":83,"description":671,"icon":84,"children":-1},"Authorization Code with PKCE against an authorization server whose tokens your API accepts.",{"title":91,"path":92,"stem":93,"description":673,"icon":94,"children":-1},"Native Google Sign-In, exchanged with your backend for your own session.",1794303128106]