Create OAuth2 session
Allow the user to login to their account using the OAuth2 provider of their choice.
/account/sessions/oauth2/{provider}Scope sessions.writeSDK: @owbase/web only
Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Owbase console first. Use the success and failure arguments to provide a redirect URL’s back to your app when login is completed.
If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user.
A user is limited to 10 active sessions at a time by default. Learn more about session limits.
Parameters
Section titled “Parameters”provider OAuthProvider required
OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. Values: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom.
success string
URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project’s platform list are allowed. This requirement helps to prevent an open redirect attack against your project API.
failure string
URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project’s platform list are allowed. This requirement helps to prevent an open redirect attack against your project API.
scopes string[]
A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
state string
An opaque value your app generates and keeps, for example in a cookie. It is returned unchanged as the state query parameter on the success and failure URLs, so your app can check that the sign-in it receives is one it started. Printable ASCII only (RFC 6749 Appendix A.5). Max length: 256 chars.
Access: no key or session: the project ID is enough.
Responses
Section titled “Responses”200Success400Invalid or missing parameter401No session, no permission on the resource or key without the scope404Resource in the path not found429Rate limitEvery error comes as JSON with code, type and message: see Errors.
import { Client, Account, OAuthProvider } from '@owbase/web';
const client = new Client() .setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>'); // Your project ID
const account = new Account(client);
account.createOAuth2Session({ provider: OAuthProvider.Amazon, success: 'https://example.com', // optional failure: 'https://example.com', // optional scopes: [], // optional state: '<STATE>', // optional});curl "https://cloud.owbase.dev/v1/account/sessions/oauth2/<PROVIDER>" \ -H "X-Owbase-Project: <PROJECT_ID>" \ -H "X-Owbase-Session: <SESSION>"No response body.
The descriptions on this page come from the server API specification (BSD-3-Clause license), and the examples come from the SDK generator (MIT license). The full notices are in the NOTICE file of the @owbase/web and @owbase/node packages.