@whop-apps/oauth
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-canary.63 • Public • Published

Whop OAuth Package

This package is designed to allow Whop Apps to interact with the Whop OAuth component that lives at https://oauth.api.whop.com. It exports both helper functions and an API wrapper to make calls to the REST API.

Usage

Usage from React

"use client";
import { initOauth } from "@whop-apps/sdk";

export const Component = () => {
	const handleGoogleLogin = useCallback(() => {
		initOAuth({
			provider: "google",
			scope: "profile email openid",
			restPath: "/oauth_callback",
		});
	}, []);

	return (
		<div>
			<button onClick={handleGoogleLogin}>Login</button>
		</div>
	);
}

Usage from the server

import { OAuthApi } from "@whop-apps/sdk";

// Retrieve an access token based on a profile ID and user ID
const accessToken = await OAuthApi({ mode: "server" }).retrieveToken({
	profile_id: "google_xxxxxxxxx",
	provider: "google",
	user_id: "user_xxxxxxxxx",
}).then((t) => t.access_token);


// Upload your credentials to the Whop OAuth API
await OAuthApi({ mode: "server" }).createCredentials({
	client_id: "YOUR_CLIENT_ID_HERE",
	client_secret: "YOUR_CLIENT_SECRET_HERE",
	provider: "google"
});

// List all profiles the user has for a specific platform
const profiles = await OAuthApi({ mode: "server" }).listProfiles({
	provider: "google",
	user_id: "user_xxxxxxxxx",
});

Readme

Keywords

none

Package Sidebar

Install

npm i @whop-apps/oauth

Weekly Downloads

162

Version

0.0.1-canary.63

License

ISC

Unpacked Size

52.1 kB

Total Files

11

Last publish

Collaborators

  • jjantschulev
  • baked-developer