Team,

I am unable pull any campaign or any other information though axios post 
call.

*here is my my code*

const axios = require("axios");

const axiosApi = async () => {
  try {
    const accessTokenObj = await axios.post(
      "https://www.googleapis.com/oauth2/v3/token";,
      new URLSearchParams({
        refresh_token: "REFRESH_TOKEN"  ,
        client_id: "CLIENT_ID",
      client_secret: "CLIENT_SECRET",
        grant_type: "refresh_token",
      }).toString()
    );
    return accessTokenObj.data.access_token;
  } catch (err) {
    console.log(err);
  }
};

*With above code i am getting access_token , and passing it to below 
function to get the campaign details.*

export const GoogleApi = async () => {
  const token = await axiosApi();

  try {
    const res = await axios
      .post(
        
`https://googleads.googleapis.com/v10/customers/${CLIENT_ID}/googleAds:searchStream`,
        {
          headers: {
            Authorization: `Bearer ${token}`,
            "Content-Type": "application/json",
            "developer-Token": "9a0BmD37ug34fehYBT_2cw",
            "login-Customer-Id": "3965620957",
          },
        }
      )
      .then((resp) => console.log(resp));

    return res;
  } catch (error) {
    console.log(error);
  }
};

export default axiosApi;


i am getting the following error. (401)

 POST 
https://googleads.googleapis.com/v10/customers/3965620957/googleAds:searchStream
 
401
dispatchXhrRequest @ xhr.js?1a5c:210
xhrAdapter @ xhr.js?1a5c:15
dispatchRequest @ dispatchRequest.js?4dc9:58
request @ Axios.js?29fb:108
Axios.<computed> @ Axios.js?29fb:140
wrap @ bind.js?4bea:9
_callee$ @ axiosApi.js?7a34:27
tryCatch @ runtime.js?ecd4:45
invoke @ runtime.js?ecd4:274
prototype.<computed> @ runtime.js?ecd4:97
asyncGeneratorStep @ axiosApi.js:10
_next @ axiosApi.js:28
Promise.then (async)
asyncGeneratorStep @ axiosApi.js:19
_next @ axiosApi.js:28
eval @ axiosApi.js:33
eval @ axiosApi.js:25
GoogleApi @ axiosApi.js?7a34:22
Home @ index.tsx?07ff:28
renderWithHooks @ react-dom.development.js?ac89:14985
mountIndeterminateComponent @ react-dom.development.js?ac89:17883
beginWork @ react-dom.development.js?ac89:19049
beginWork$1 @ react-dom.development.js?ac89:23940
performUnitOfWork @ react-dom.development.js?ac89:22776
workLoopSync @ react-dom.development.js?ac89:22707
renderRootSync @ react-dom.development.js?ac89:22670
performSyncWorkOnRoot @ react-dom.development.js?ac89:22293
scheduleUpdateOnFiber @ react-dom.development.js?ac89:21881
updateContainer @ react-dom.development.js?ac89:25482
eval @ react-dom.development.js?ac89:26021
unbatchedUpdates @ react-dom.development.js?ac89:22431
legacyRenderSubtreeIntoContainer @ react-dom.development.js?ac89:26020
hydrate @ react-dom.development.js?ac89:26086
renderReactElement @ index.js?46cb:515
doRender @ index.js?46cb:831
_callee$ @ index.js?46cb:408
tryCatch @ runtime.js?ecd4:45
invoke @ runtime.js?ecd4:274
prototype.<computed> @ runtime.js?ecd4:97
asyncGeneratorStep @ index.js?46cb:30
_next @ index.js?46cb:48
eval @ index.js?46cb:53
eval @ index.js?46cb:45
_render @ index.js?46cb:427
render @ index.js?46cb:430
_callee$ @ index.js?46cb:394
tryCatch @ runtime.js?ecd4:45
invoke @ runtime.js?ecd4:274
prototype.<computed> @ runtime.js?ecd4:97
asyncGeneratorStep @ index.js?46cb:30
_next @ index.js?46cb:48
Promise.then (async)
asyncGeneratorStep @ index.js?46cb:39
_next @ index.js?46cb:48
Promise.then (async)
asyncGeneratorStep @ index.js?46cb:39
_next @ index.js?46cb:48
Promise.then (async)
asyncGeneratorStep @ index.js?46cb:39
_next @ index.js?46cb:48
eval @ index.js?46cb:53
eval @ index.js?46cb:45
_initNext @ index.js?46cb:396
initNext @ index.js?46cb:399
eval @ next-dev.js?3515:44
./node_modules/next/dist/client/next-dev.js @ main.js?ts=1648125085728:148
options.factory @ webpack.js?ts=1648125085728:606
__webpack_require__ @ webpack.js?ts=1648125085728:37
__webpack_exec__ @ main.js?ts=1648125085728:744
(anonymous) @ main.js?ts=1648125085728:745
webpackJsonpCallback @ webpack.js?ts=1648125085728:1152
(anonymous) @ main.js?ts=1648125085728:9
Show 20 more frames
axiosApi.js?7a34:42 Error: Request failed with status code 401
    at createError (createError.js?770c:16:1)
    at settle (settle.js?8768:17:1)
    at XMLHttpRequest.onloadend (xhr.js?1a5c:66:1)

POST 
https://googleads.googleapis.com/v10/customers/3965620957/googleAds:searchStream
 
401

*Can someone help us on this please ?*

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/cd4a66c6-a0a9-4481-b71e-37b709e99e02n%40googlegroups.com.

Reply via email to