sandrinodimattia / use-auth0-hooks

An easy way to sign in with Auth0 in your React application (client-side) using React Hooks
https://nextjs-spa-auth0-demo.now.sh/
MIT License
74 stars 31 forks source link

useAccessToken? #25

Open moxious opened 4 years ago

moxious commented 4 years ago

Setup instructions include this bit for getting an access token for an API:

When I do this, the useAccessToken function isn't actually used anywhere in the example and is undefined anyway -- but other than audience and scope this is the only difference API invocation between other examples. It seems to have no effect, but since I've been unable to get access tokens from my auth0 app, it's also unclear what it would have accomplished here.

Request please to clarify what this example is doing, or otherwise remove useAccessToken as it appears to have no effect.

import { useAuth, useAccessToken } from 'use-auth0-hooks';

export function SomePage() {
  const { accessToken } = useAuth({
    audience: 'https://api.mycompany.com/',
    scope: 'read:things'
  });

  const { response, isLoading } = callMyApi(`https://localhost/api/my/shows`, accessToken);
  if (isLoading) {
    return (
      <div>Loading your subscriptions ...</div>
    );
  }

  return (
    <div>API call response: {response}</div>
  );
}
msembinelli commented 4 years ago

useAccessToken does not exist afaik Additionally, accessToken functionality in this version of the library seems broken. I made some fixes and have it working on my fork, give it a try: https://github.com/msembinelli/use-auth0-hooks

seveibar commented 4 years ago

For those wondering how to install @msembinelli's package, just run the following:

npm remove use-auth0-hooks
npm install --save "github:msembinelli/use-auth0-hooks"

Thanks @msembinelli for putting it together, it seems Auth0 is not being the best steward of this package at the moment (no commits for ~6 months at the time of writing)

sandrinodimattia commented 4 years ago

All of the concepts of this library have been moved to the official Auth0 SDK for React (https://github.com/auth0/auth0-react), so I'll be archiving this repository shortly.