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

167
Views
Jquery AJAX/FETCH : https://www.googleapis.com/oauth2/v3/token' from origin 'null' has been blocked by CORS policy

I am getting an error from generate token in google oauth API.

error:https://www.googleapis.com/oauth2/v3/token' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

  fetch("https://www.googleapis.com/oauth2/v3/token", {
      method: "POST",
      headers: new Headers({
        "Access-Control-Allow-Origin": window.location.origin,
        "Access-Control-Allow-Methods": "DELETE, GET, POST, PUT",
        "Access-Control-Allow-Header": "X-Requested-With,content-type",
        "Access-Control-Allow-Credentials": true,
      }),
      body: JSON.stringify({
        redirect_uri: redirect_uri,
        client_secret: client_secret,
        client_id: client_id,
        refresh_token: refresh_token,
        scope: scope,
        grant_type: "refresh_token",
      }),
    })
      .then((res) => res.json())
      .then((res) => {
        console.log(res);
        localStorage.setItem("accessToken", res.access_token);
        localStorage.setItem("refreshToken", res.refreshToken);
        localStorage.setItem("expires_in", res.expires_in);
      });
about 4 years ago · Santiago Trujillo
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!