Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
How can i consult data from an Oauth2.0 api in multiple pages using only one access token in react?

I need to create an access token and use him to get infos from an api in multiples pages. I made the access token by this code


(async () => {
    const clientId = 'XXXXXXXXXXXX'
    const clientSecret = 'XXXXXXXXXXXXXXXXXX'
    const encodedData = Buffer.from(clientId + ':' + clientSecret).toString('base64');
    var accessToken = ''
    var response = {}
    console.log('Encoded data: ' + encodedData)
    console.log('authorization', 'Basic ' + encodedData)
    // POST request using axios with async/await
    try { 
        response = await axios.post('XXXXXXXXXXXXXXXXXXXXXXXXXXXX', {}, {
            headers: { 'Authorization': 'Basic ' + encodedData }
        });
        console.log(response.status, response.statusText, response.data.access_token);
        accessToken = response.data.access_token;
    } catch(error) {
        console.log('XXXXXXXXXXXXXXXXXXXXXXXXXXXX' , error.message);
    }

how can i use him in the pages to get the api data ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!