Not able to generate network report with admob api

78 views
Skip to first unread message

Monazir Hussain

unread,
Dec 12, 2022, 3:47:17 AM12/12/22
to AdMob API Developer Forum
Not able to generate network report with admob api. Attached below request for reference

curl -X POST \
      https://admob.googleapis.com/v1/accounts/pub-************/networkReport:generate \
      -H "Content-Type: application/json" \
      -H "$(oauth2l header --json credentials.json \
          https://www.googleapis.com/auth/admob.report)" \
      --data @- << EOF
{
"report_spec":{
  "date_range": {
    "start_date": {"year": 2022, "month": 12, "day": 1},
     "end_date": {"year": 2022, "month": 12, "day": 1}
  },
  "dimensions": ["DATE", "AD_UNIT", "APP", "COUNTRY", "FORMAT", "PLATFORM" ],
  "metrics": ["AD_REQUESTS", "CLICKS", "ESTIMATED_EARNINGS", "IMPRESSIONS", "IMPRESSION_CTR", "MATCHED_REQUESTS", "MATCH_RATE"]
}
}
EOF
[{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}
]%

AdMob API Forum Support

unread,
Dec 13, 2022, 3:59:08 PM12/13/22
to google-admob-api...@googlegroups.com
Hi there,

Please ensure you have completed all of the authorization setup steps. The next step will be to copy the command below into your terminal and check that you retrieve a token. Prior to running the command, please replace PATH_TO_CREDENTIALS with your credentials.json file that is retrieved during the authorization setup steps.
 
~/go/bin/oauth2l header --json PATH_TO_CREDENTIALS https://www.googleapis.com/auth/admob.readonly

All the best,

Google Logo
Amira
AdMob API Team
 


ref:_00D1U1174p._5004Q2h1vN8:ref
Message has been deleted

AdMob API Forum Support

unread,
Dec 15, 2022, 2:34:24 PM12/15/22
to monazir...@moonfroglabs.com, naman...@moonfroglabs.com, karan....@moonfroglabs.com, google-admob-api...@googlegroups.com
Hi there,

Thank you for the screenshot. I believe this issue is being cause by a curl formatting error, please try removing all of the backslashes "\" and submitting the request on a single line as shown below.
curl -X POST https://admob.googleapis.com/v1/accounts/pub-*************/networkReport:generate -H "Content-Type: application/json" -H "$(~/go/bin/oauth2l header --json credentials.json https://www.googleapis.com/auth/admob.readonly)" --data @- << EOF
{
"report_spec":{
  "date_range": {
    "start_date": {"year": 2022, "month": 12, "day": 1},
     "end_date": {"year": 2022, "month": 12, "day": 1}
  },
  "dimensions": ["DATE", "AD_UNIT", "APP", "COUNTRY", "FORMAT", "PLATFORM" ],
  "metrics": ["AD_REQUESTS", "CLICKS", "ESTIMATED_EARNINGS", "IMPRESSIONS", "IMPRESSION_CTR", "MATCHED_REQUESTS", "MATCH_RATE"]
}
}
EOF

Please let me know if this does not resolve your issue.

All the best,

Monazir Hussain

unread,
Dec 16, 2022, 12:14:37 AM12/16/22
to AdMob API Forum Support, naman...@moonfroglabs.com, karan....@moonfroglabs.com, google-admob-api...@googlegroups.com
Hello There,

It's not working, at all. Response is still the same. Please let me know what I'm doing wrong here. 

image.png


Thanks
Monazir

AdMob API Forum Support

unread,
Dec 19, 2022, 1:12:23 PM12/19/22
to monazir...@moonfroglabs.com, naman...@moonfroglabs.com, karan....@moonfroglabs.com, google-admob-api...@googlegroups.com
Hello,

I was unable to reproduce the issue, so I recommend trying to use the API explorer to generate a network request. If you are able to successfully authenticate using the API explorer, found on the right hand side of the page, the issue is likely due to improper project setup. I would then recommend creating a new cloud project and following the Auth setup page from the start for a clean environment.

Monazir Hussain

unread,
Dec 20, 2022, 12:46:40 AM12/20/22
to AdMob API Forum Support, naman...@moonfroglabs.com, karan....@moonfroglabs.com, google-admob-api...@googlegroups.com
Hello,
I've also tried it on the API explorer page, but it's resulting same response.

image.png
Thanks
Monazir



AdMob API Forum Support

unread,
Dec 23, 2022, 12:38:27 PM12/23/22
to monazir...@moonfroglabs.com, naman...@moonfroglabs.com, karan....@moonfroglabs.com, google-admob-api...@googlegroups.com
Hello,

I recommend creating a new google cloud platform project and following the Auth setup page from the start for a clean environment and to confirm all steps were followed. Please ensure that you are signed in to the correct account when accepting the consent screen.

Monazir Hussain

unread,
Dec 30, 2022, 2:02:37 AM12/30/22
to AdMob API Forum Support, naman...@moonfroglabs.com, karan....@moonfroglabs.com, google-admob-api...@googlegroups.com
Hello ,
I created a new project, but got an error while configuring the consent screen.
Attached screenshot for reference.
image.png

Thanks
Monazir

AdMob API Forum Support

unread,
Jan 4, 2023, 12:16:46 AM1/4/23
to monazir...@moonfroglabs.com, naman...@moonfroglabs.com, karan....@moonfroglabs.com, google-admob-api...@googlegroups.com
Hello,

I recommend following the guide that describes Setting Up Your OAuth Consent Screen. If you have additional issues regarding the OAuth consent screen, please reach out to the Google Cloud Platform Console Help Center.

Monazir Hussain

unread,
Jan 9, 2023, 4:52:20 AM1/9/23
to AdMob API Forum Support, naman...@moonfroglabs.com, karan....@moonfroglabs.com, google-admob-api...@googlegroups.com
Hello,

Now I'm getting a different error while trying to get below data. Attached screenshot for your reference.
{
  "reportSpec": {
    "dateRange": {
      "startDate": {
        "year": 2023,
        "month": 1,
        "day": 1
      },
      "endDate": {
        "year": 2023,
        "month": 1,

        "day": 1
      }
    },
    "dimensions": [
      "DATE",
      "AD_UNIT",
      "APP",
      "COUNTRY",
      "FORMAT",
      "PLATFORM"
    ],
    "metrics": [
      "AD_REQUESTS",
      "CLICKS",
      "ESTIMATED_EARNINGS",
      "IMPRESSIONS",
      "IMPRESSION_CTR",
      "MATCHED_REQUESTS",
      "MATCH_RATE"
    ]
  }
}

Screenshot 2023-01-09 at 3.19.47 PM.png 

AdMob API Forum Support

unread,
Jan 9, 2023, 2:04:16 PM1/9/23
to monazir...@moonfroglabs.com, naman...@moonfroglabs.com, karan....@moonfroglabs.com, google-admob-api...@googlegroups.com
Hello,

Did you retry the request 30 seconds after the initial error and did you receive the same error response? I recommend using the API explorer to make a request and if there are issues with the API explorer, to then try the request below in a terminal.
 
curl -X GET https://admob.googleapis.com/v1/accounts/pub-************* -H "Content-Type: application/json" -H "$(~/go/bin/oauth2l header --json credentials.json https://www.googleapis.com/auth/admob.readonly)"

Monazir Hussain

unread,
Jan 16, 2023, 1:07:04 PM1/16/23
to AdMob API Forum Support, naman...@moonfroglabs.com, karan....@moonfroglabs.com, google-admob-api...@googlegroups.com
Hello,

Now I'm able to download the report after getting the access token, but it needs to be approved every time from the browser.
But It is not possible for us to do it as it will be running on a virtual machine.
As far as I could find It can be done with refresh token and refreshing access token when expired. 
But I didn't find any resources to do this for Desktop project admob api. 
Could you please help me with this?? 

Thanks
Monazir

AdMob API Forum Support

unread,
Jan 17, 2023, 3:08:48 PM1/17/23
to monazir...@moonfroglabs.com, naman...@moonfroglabs.com, karan....@moonfroglabs.com, google-admob-api...@googlegroups.com
Hello,

I recommend using a web app authentication type for your application. The desktop authorization flow is similar to the one used for web server applications. The main difference is that installed apps must open the system browser and supply a local redirect URI to handle responses from Google's authorization server. 
Reply all
Reply to author
Forward
0 new messages