Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No access token provided" error even if fetchToken function is provided. #211

Open
GabrielMusatMestre opened this issue Apr 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@GabrielMusatMestre
Copy link

Describe the bug

When fresh starting the React application, a lot of errors like this are thrown:

@propeldata_ui-kit.js?v=d0ba27f7:23550 No access token provided.

Even though the fetchToken function is provided to AccessTokenProvider.

After 10-15 errrors thrown, it stops (at this point, the Oauth server responded with the token correctly)

To reproduce

This is the code for my whole application:

import { Counter, AccessTokenProvider } from '@propeldata/ui-kit'
import { ClientCredentials } from 'simple-oauth2';

import './App.css'

const dataPool = import.meta.env.VITE_DATA_POOL_ID

function App() {
  return (
    <AccessTokenProvider fetchToken={fetchToken}>
      <Counter
        style={{ width: 100, height: 100 }}
        query={{
          metric: {
            count: {
              dataPool: { id: dataPool }
            }
          }
        }}
      />
    </AccessTokenProvider>
  )
}

export default App

async function fetchToken(): Promise<string> {
  const client = new ClientCredentials({
    client: {
      id: import.meta.env.VITE_CLIENT_ID,
      secret: import.meta.env.VITE_CLIENT_SECRET
    },
    auth: {
      tokenHost: "https://auth.us-east-2.propeldata.com",
      tokenPath: "/oauth2/token"
    }
  });
  const accessToken = await client.getToken({});
  return accessToken.token.access_token as string;
}

Screenshots or video

Screenshot 2024-04-11 at 12 28 50

Desktop (please complete the following information)

  • OS: macOS
  • Browser: Chrome
  • UI Kit Version: 0.5.5
@GabrielMusatMestre GabrielMusatMestre added the bug Something isn't working label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant