@openauth/youtube

OAuth youtube library.

Usage no npm install needed!

<script type="module">
  import openauthYoutube from 'https://cdn.skypack.dev/@openauth/youtube';
</script>

README

Open Auth - Youtube

Downloads Version License Typescript dependencies Status

@openauth/youtube is an implementation of Youtube OAuth.

Installation

npm i @openauth/youtube

Usage

import { YoutubeOAuth } from '@openauth/youtube'

const oauth = new YoutubeOAuth({
  clientId: 'client_id',
  clientSecret: 'client_secret',
  redirectUri: 'https://wani.kr/auth/youtube/callback',
})


// 1. After getting auth request uri, connect.
const redirectUri = await oauth.getAuthRequestUri()

// 2. It redirects with the code, and replaces the access token with this code value.
const { accessToken } = await oauth.getAccessTokenResponse(code)

// 3. Get user profile.
await oauth.getAuthUser(accessToken)

// 4. Other API
await oauth.getClient(accessToken).get({
  path: 'youtube/v3/channels',
  query: {
    part: 'snippet',
    mine: 'true',
  },
})