import{S as je,i as Fe,s as Ve,M as He,e as s,w as g,b as h,c as re,f as p,g as r,h as a,m as ce,x as ue,N as Pe,O as Le,k as Ee,P as Je,n as Ne,t as E,a as J,o as c,d as de,T as ze,C as Re,p as Ie,r as N,u as Ke}from"./index-ddcbddc8.js";import{S as Qe}from"./SdkTabs-352951b8.js";function xe(i,l,o){const n=i.slice();return n[5]=l[o],n}function We(i,l,o){const n=i.slice();return n[5]=l[o],n}function Ue(i,l){let o,n=l[5].code+"",m,k,u,b;function _(){return l[4](l[5])}return{key:i,first:null,c(){o=s("button"),m=g(n),k=h(),p(o,"class","tab-item"),N(o,"active",l[1]===l[5].code),this.first=o},m(v,A){r(v,o,A),a(o,m),a(o,k),u||(b=Ke(o,"click",_),u=!0)},p(v,A){l=v,A&4&&n!==(n=l[5].code+"")&&ue(m,n),A&6&&N(o,"active",l[1]===l[5].code)},d(v){v&&c(o),u=!1,b()}}}function Be(i,l){let o,n,m,k;return n=new He({props:{content:l[5].body}}),{key:i,first:null,c(){o=s("div"),re(n.$$.fragment),m=h(),p(o,"class","tab-item"),N(o,"active",l[1]===l[5].code),this.first=o},m(u,b){r(u,o,b),ce(n,o,null),a(o,m),k=!0},p(u,b){l=u;const _={};b&4&&(_.content=l[5].body),n.$set(_),(!k||b&6)&&N(o,"active",l[1]===l[5].code)},i(u){k||(E(n.$$.fragment,u),k=!0)},o(u){J(n.$$.fragment,u),k=!1},d(u){u&&c(o),de(n)}}}function Ge(i){let l,o,n=i[0].name+"",m,k,u,b,_,v,A,D,z,S,j,he,F,M,pe,I,V=i[0].name+"",K,be,Q,P,G,R,X,x,Y,y,Z,fe,ee,$,te,me,ae,ke,f,ge,C,_e,ve,we,le,Oe,oe,Ae,Se,ye,se,$e,ne,W,ie,T,U,O=[],Te=new Map,Ce,B,w=[],qe=new Map,q;v=new Qe({props:{js:` import PocketBase from 'pocketbase'; const pb = new PocketBase('${i[3]}'); ... // OAuth2 authentication with a single realtime call. // // Make sure to register ${i[3]}/api/oauth2-redirect as redirect url. const authData = await pb.collection('users').authWithOAuth2({ provider: 'google' }); // OR authenticate with manual OAuth2 code exchange // const authData = await pb.collection('users').authWithOAuth2Code(...); // after the above you can also access the auth data from the authStore console.log(pb.authStore.isValid); console.log(pb.authStore.token); console.log(pb.authStore.model.id); // "logout" the last authenticated model pb.authStore.clear(); `,dart:` import 'package:pocketbase/pocketbase.dart'; import 'package:url_launcher/url_launcher.dart'; final pb = PocketBase('${i[3]}'); ... // OAuth2 authentication with a single realtime call. // // Make sure to register ${i[3]}/api/oauth2-redirect as redirect url. final authData = await pb.collection('users').authWithOAuth2('google', (url) async { await launchUrl(url); }); // OR authenticate with manual OAuth2 code exchange // final authData = await pb.collection('users').authWithOAuth2Code(...); // after the above you can also access the auth data from the authStore print(pb.authStore.isValid); print(pb.authStore.token); print(pb.authStore.model.id); // "logout" the last authenticated model pb.authStore.clear(); `}}),C=new He({props:{content:"?expand=relField1,relField2.subRelField"}});let L=i[2];const De=e=>e[5].code;for(let e=0;ee[5].code;for(let e=0;eAuthenticate with an OAuth2 provider and returns a new auth token and record data.

For more details please check the OAuth2 integration documentation .

`,_=h(),re(v.$$.fragment),A=h(),D=s("h6"),D.textContent="API details",z=h(),S=s("div"),j=s("strong"),j.textContent="POST",he=h(),F=s("div"),M=s("p"),pe=g("/api/collections/"),I=s("strong"),K=g(V),be=g("/auth-with-oauth2"),Q=h(),P=s("div"),P.textContent="Body Parameters",G=h(),R=s("table"),R.innerHTML=`Param Type Description
Required provider
String The name of the OAuth2 client provider (eg. "google").
Required code
String The authorization code returned from the initial request.
Required codeVerifier
String The code verifier sent with the initial request as part of the code_challenge.
Required redirectUrl
String The redirect url sent with the initial request.
Optional createData
Object

Optional data that will be used when creating the auth record on OAuth2 sign-up.

The created auth record must comply with the same requirements and validations in the regular create action.
The data can only be in json, aka. multipart/form-data and files upload currently are not supported during OAuth2 sign-ups.

`,X=h(),x=s("div"),x.textContent="Query parameters",Y=h(),y=s("table"),Z=s("thead"),Z.innerHTML=`Param Type Description`,fe=h(),ee=s("tbody"),$=s("tr"),te=s("td"),te.textContent="expand",me=h(),ae=s("td"),ae.innerHTML='String',ke=h(),f=s("td"),ge=g(`Auto expand record relations. Ex.: `),re(C.$$.fragment),_e=g(` Supports up to 6-levels depth nested relations expansion. `),ve=s("br"),we=g(` The expanded relations will be appended to the record under the `),le=s("code"),le.textContent="expand",Oe=g(" property (eg. "),oe=s("code"),oe.textContent='"expand": {"relField1": {...}, ...}',Ae=g(`). `),Se=s("br"),ye=g(` Only the relations to which the request user has permissions to `),se=s("strong"),se.textContent="view",$e=g(" will be expanded."),ne=h(),W=s("div"),W.textContent="Responses",ie=h(),T=s("div"),U=s("div");for(let e=0;eo(1,k=_.code);return i.$$set=_=>{"collection"in _&&o(0,m=_.collection)},i.$$.update=()=>{i.$$.dirty&1&&o(2,u=[{code:200,body:JSON.stringify({token:"JWT_AUTH_TOKEN",record:Re.dummyCollectionRecord(m),meta:{id:"abc123",name:"John Doe",username:"john.doe",email:"test@example.com",avatarUrl:"https://example.com/avatar.png",accessToken:"...",refreshToken:"...",rawUser:{}}},null,2)},{code:400,body:` { "code": 400, "message": "An error occurred while submitting the form.", "data": { "provider": { "code": "validation_required", "message": "Missing required value." } } } `}])},o(3,n=Re.getApiExampleUrl(Ie.baseUrl)),[m,k,u,n,b]}class et extends je{constructor(l){super(),Fe(this,l,Xe,Ge,Ve,{collection:0})}}export{et as default};