0.5.0-alpha.2 • Published 2 years ago

@openauth/instagram v0.5.0-alpha.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Open Auth - Instagram

@openauth/instagram is an implementation of Instagram OAuth.

See Instagram Basic Display API Document.

Installation

npm i @openauth/instagram

Usage

import { InstagramOAuth } from '@openauth/instagram'

const oauth = new InstagramOAuth({
  clientId: 'client_id',
  clientSecret: 'client_secret',
  redirectUri: 'https://wani.kr/auth/instagram/callback',
  scope: [
    'user_profile',
    'user_media',
  ],
})

// 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: 'me',
  query: {
    fields: [
      'id',
      'username',
      'account_type',
      'media_count',
    ].join(','),
  },
})