0.0.5 • Published 3 years ago

opentidal v0.0.5

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

Example usage

import { auth } from "openTIDAL"

const client_id = "client_id"
const client_secret = "client_secret"

;(async () => {
  // get a device token to start the auth process
  const deviceToken = await auth.getDeviceToken({ client_id })

  // prints something like https://link.tidal.com/ABCDE
  // go to the provided URI and authorize the device
  console.log(`authorize via https://${deviceToken.verificationUriComplete}`)

  let accessToken

  // poll this endpoint until authorization is complete
  const interval = setInterval(async () => {
    console.log("checking if authorized")
    accessToken = await auth.getAccessToken({
      client_id,
      client_secret,
      device_code: deviceToken.deviceCode,
    })

    // if the response contains an access_token, you're authenticated!
    if ("access_token" in accessToken) {
      clearInterval(interval)
      console.log("access_token:", accessToken.access_token)
    }
  }, deviceToken.interval * 1000)
})()
0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago