AdMob : How to query admob for my app earnings - service

I've already configured adMob for my Android apps and have no problem with that.
Right now I'm looking for any way to check my apps earnings (if possible for each of the apps separately) in any given moment.
Somebody knows if there's any API, library or Web Service I can use to access my AdMob account and get info about my apps' statistics and so on ?
I've already checked the official APK but it seems only intended to show the ads in your app and nothing else.
Thanks in advance

I answer myself.
I was doing some research, and I found that after the recent changes on AdMob, and the migration to AdSense, you must use the AdSense API to get this info.
In particular, each Android app is associated with a "adunit" id, so if you want to check the info of any particular app you might use:
https://developers.google.com/adsense/management/v1.4/reference/accounts/reports/generate
with the following data:
accountId = your Publisher ID (pub-XXXXXXX)
startDate and endDate = The interval of dates you want to check
dimension = AD_UNIT_ID
metric = EARNINGS
With this query you'll have the required info, separated by App.
You get the results in JSON form.

There is an AdMob API available to get the AdMob specific data.
It provides a possibility to generate network and mediation reports available. It could be as simple as:
curl -X POST https://admob.googleapis.com/v1/accounts/<your_publisher_id>/mediationReport:generate \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
--data #- << EOF
{
"report_spec": {
"date_range": {
"start_date": {"year": 2020, "month": 4, "day": 1},
"end_date": {"year": 2020, "month": 4, "day": 1}
},
"dimensions": ["AD_SOURCE", "AD_UNIT", "PLATFORM"],
"metrics": ["ESTIMATED_EARNINGS"]
}
}
EOF
.net: https://developers.google.com/api-client-library/dotnet/apis/admob/v1
java: https://github.com/googleapis/google-api-java-client-services/tree/master/clients/google-api-services-admob/v1
Get an Oauth2.0 access token
With oauth2l
install: https://github.com/google/oauth2l
oauth2l header --json <path_to_secret_json> https://www.googleapis.com/auth/admob.report
path_to_secret_json - is one from the credentials page on the google cloud console.
With curl
Replace the oauth2_client_id with the one you have in your “Cloud project credentials - OAuth 2.0 client IDs” page. (https://console.developers.google.com/apis/credentials?project=)
https://accounts.google.com/o/oauth2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadmob.report&response_type=code&client_id=&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob
Open this link in incognito browser mode;
Follow the instruction, and accept the consonant screen with AdMob publisher's account;
Copy the code, it would be needed for the following request:
curl -L \
-d "client_id=<oauth2_client_id>" \
-d "client_secret=<oauth2_secret>" \
-d "grant_type=authorization_code" \
-d "code=<sign_in_code_from_the_previous_step>" \
-d "redirect_uri=urn:ietf:wg:oauth:2.0:oob" \
https://accounts.google.com/o/oauth2/token
oaut2_client_id and oauth2_secret can be found on the OAuth 2.0 client Id page.
Response:
{
"access_token": "<access_token>",
"expires_in": 3600,
"refresh_token": "<refresh_token>",
"scope": "https://www.googleapis.com/auth/admob.report",
"token_type": "Bearer"
}

Related

PayPal Onboard sellers before payment

I am trying to create an application that enables sellers to create a PayPal account which then my platform will use their PayPal details to payout them whenever a pucharse is made via the application. I checked the documentation for creating a seller onboarding sign-up link but I couldn't able to figure out how to use this in the NodeJS environment.
curl -v -X POST https://api-m.sandbox.paypal.com/v2/customer/partner-referrals \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <Access-Token>" \
-d '{
"tracking_id": "<Tracking-ID>",
"operations": [
{
"operation": "API_INTEGRATION",
"api_integration_preference": {
"rest_api_integration": {
"integration_method": "PAYPAL",
"integration_type": "THIRD_PARTY",
"third_party_details": {
"features": [
"PAYMENT",
"REFUND"
]
}
}
}
}
],
"products": [
"EXPRESS_CHECKOUT"
],
"legal_consents": [
{
"type": "SHARE_DATA_CONSENT",
"granted": true
}
]
}'
There is no SDK for such APIs, but you could use the code (for other APIs) in Checkout-NodeJS-SDK as a starting point and use it to create your own HTTPS calls for this API you want to integrate, based on that curl sample.
Alternatively, use one of the many HTTPS request libraries available for NodeJS, such as axios or got, to implement the request of that curl sample. You will need to implement an Oauth2 request first to get an Access Token with the clientid/secret.

How to set default namesevers for a Google Cloud DNS zone?

I'm using Google's CloudDNS API to batch upload a bunch of domains to Google Cloud. I want to be able to override the default nameservers that Google randomly assigns for example
ns-cloud-e1.google.com
ns-cloud-e2.google.com
ns-cloud-e3.google.com
ns-cloud-e4.google.com
to
n1.domain.com
n2.domain.com
n3.domain.com
I've noticed that Google's CloudDNS API's documentation references the following
nameServerSet (string) -
Optionally specifies the NameServerSet for this ManagedZone. A
NameServerSet is a set of DNS name servers that all host the same
ManagedZones. Most users will leave this field unset.
Though when trying to use this property via the CloudDNS, I receive a response from the API saying that the data provided through data is invalid. I passed through in the format of "n1.domain.com.,n2.domain.com.,n3.domain.com.". I've also tried passing through an array of nameservers and a RecordResourceSet class from the Google PHP package, with no avail.
Is this the correct format I should be following or is it not possible to pre-define the nameservers when the managed zone is created and instead have to do this after the zone is created?
Code example below, $cloud_dns->service is an instance of Google_Service_Dns
$cloud_dns->service->managedZones
->create(
'blah',
new Google_Service_Dns_ManagedZone([
'dnsName' => $dns_name_formatted,
'name' => 'app-' . $domain_name,
'description' => 'Batch Uploaded Domain',
'nameServerSet' => 'n1.domain.com.,n2.domain.com.,n3.domain.com.'
]),
);
You may wish to consider filing this issue with Google's public Issue Tracker.
You're not the first to encounter this and that question is 4 years old and remains unanswered :-(
Regardless of language SDK, the underlying call can be tested using Google's APIs Explorer and specifically ManagedZones:create which conveniently includes the relevant API method. You can plug in your values and try it out (securely) within the browser, or:
NAME="yourdomain-com"
DNS="yourdomain.com." # Must end with a period (.)
TOKEN=$(gcloud auth print-access-token)
curl \
--request POST \
--header "Authorization: Bearer ${TOKEN}" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data "{\"nameServerSet\":\"n1.domain.com.,n2.domain.com.\",\"name\":\"${NAME}\",\"dnsName\":\"${DNS}\",\"description\":\"\"}" \
"https://dns.googleapis.com/dns/v1/projects/${PROJECT}/managedZones"
I tried to craft a request using nameServerSet using the API directly and am unable. It's thus not a language SDK issue but a question of whether|how this property may be set.
It's somewhat interesting to note that you can't set name servers when creating zones through the console (link). But, you may subsequently change them. The console POSTs to ManagedZone:changes, e.g.:
POST https://www.googleapis.com/dns/v1beta2/projects/${PROJECT}/managedZones/${NAME}/changes
{
"additions": [
{
"name": "...",
"type": "NS",
"ttl": 21600,
"rrdatas": [
"ns-cloud-d1.googledomains.com.",
"ns-cloud-d3.googledomains.com.",
"ns-cloud-d4.googledomains.com."
]
}
],
"deletions": [
{
"name": "...",
"type": "NS",
"ttl": 21600,
"rrdatas": [
"n1.domain.com.",
"n2.domain.com.",
"n3.domain.com."
]
}
]
}

How do I create a JWT Token for Prime Trust's API?

I am working with Prime Trust's API and I'm unable to create a JWT token. I am following the documentation which states the following:
Getting Started with the Custody APIs - (Sandbox Specific)
You need totake the current steps to get started via the APIs
Create a new User
Authenticate with the APIs by getting a JWT.
Create an Account.
Test Mode APIs - Approve the owner of the account for CIP and AML.
Test Mode APIs - Open an Account for Funds
I was able to create a user following the documentation, but I'm stuck on the creation of the JWT Token. According to the documentation I should create the token using the below:
JSON Web Tokens (JWTs)
JSON Web Tokens or JWTs are the preferred method of authentication for all requests besides actually generating a JWT. Since JWTs are not persisted server resources, they are not created using a JSONAPI style request or response.
Creating a new JWT
A new JWT can be created by passing a user's credentials using HTTP
Basic Authorization to the following endpoint. Any special settings on
the JWT such as IP whitelisting, expiration time or TOTP MFA must be
passed in as form values during creation.
POST /auth/jwts
Here's the example call they give:
curl --location --request POST "https://sandbox.primetrust.com/auth/jwts" \
--header "Content-Type: application/x-www-form-urlencoded" \
--form "expires_at=2019-06-06T07:30:40Z" \
--form "otp=382948" \
--form "cidr[]=192.168.1.213/32" \
--form "cidr[]=127.0.0.1/32"
I've tried a combination of different calls with the details outlined below, but have the below error on all of my attempts:
401 Unauthorized
{
"errors": [
{
"status": 401,
"title": "Not authenticated."
}
]
}
Bodies
POST https://sandbox.primetrust.com/auth/jwts
POST https://sandbox.primetrust.com/auth/jwts
{
"email": "email#email.com",
"password": "123abc"
}
POST https://sandbox.primetrust.com/auth/jwts
{
"data": {
"email": "email#email.com",
"password": "123abc"
}
}
POST https://sandbox.primetrust.com/auth/jwts
{
"name": "name",
"email": "email#email.com",
"password": "123abc"
}
POST https://sandbox.primetrust.com/auth/jwts
{
"id": {guid},
"name": "name",
"email": "email#email.com",
"password": "123abc"
}
POST https://sandbox.primetrust.com/auth/jwts
{
"id": {guid},
"password": "123abc"
}
Headers
Content-Type: application/json
expires_at: 2019-12-31T11:59:59Z
alg: HS256
typ: JWT
I recognize that my calls don't line up with the example call exactly, but my understanding from the documentation is that all that should be required is a name & password to generate the JWT token. What am I missing?
Update 1
Based on reaching out to Prime Trust support the username/email need to be included as parameters rather than in the body of the url. I tried the below URLs without success
https://sandbox.primetrust.com/auth/jwts?email=email#email.com&password=123abc&id={guid}
https://sandbox.primetrust.com/auth/jwts?email=email#email.com&password=123abc
https://sandbox.primetrust.com/auth/jwts?password=123abc&id={guid}
https://sandbox.primetrust.com/auth/jwts?name=name&password=123abc
According to docs:
Creating a new JWT
A new JWT can be created by passing a user's credentials using HTTP Basic Authorization to the following endpoint. Any special settings on the JWT such as IP whitelisting, expiration time or TOTP MFA must be passed in as form values during creation.
So basically all you need is create an Authorization header set to Basic Auth with your credentials:
curl -X POST \
https://sandbox.primetrust.com/auth/jwts \
-H 'Authorization: Basic YOUR_BASE64_ENCODED_EMAIL_AND_PASSWORD' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'cache-control: no-cache'

Getting "Authorization has been denied for this request." when attempting to create a channel in Teams

I am getting this rather unhelpful error and it seems to occur for a large variety of things based on the SO posts. So here I am.
I went here https://apps.dev.microsoft.com, logged in and created a new App. I generated a secret and stored it for later on a post-it note... I granted "Group.ReadWrite.All" under "Delegate" as the create channel API doc says I should. I left everything else in the App as default.
I then do a token request like so:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \
"https://login.microsoftonline.com/$TENANT/oauth2/v2.0/token" \
-d "client_id=$APP_ID" -d "scope=https%3A%2F%2Fgraph.microsoft.com%2F.default" \
-d "client_secret=$PASSWORD" -d "grant_type=client_credentials"
which gives me this mess:
{"token_type":"Bearer","expires_in":3600,"ext_expires_in":0,"access_token":"BIG_LONG_TOKEN"}
I then take that token and stuff it into my Authorization header and make the call to create the channel:
curl "https://graph.microsoft.com/beta/groups/$TENANT/channels" \
-H "Content-type: application/json" \
-H "Authorization: Bearer $BIG_LONG_TOKEN" \
-d '{
"displayName": "mynewchannel",
"description": "Channel Description"
}'
But this results in tears and this:
{
"error": {
"code": "",
"message": "Authorization has been denied for this request.",
"innerError": {
"request-id": "c572f6df-7537-4a53-aefc-fcc8c71e2037",
"date": "2018-04-17T23:46:50"
}
}
}
I am not sure what I'm missing, but hopefully it's obvious to someone else...
EDIT: Interestingly, if I set TOKEN to garbage, I get a more helpful answer, but this indicates my TOKEN is at least mostly ok and it is more of a authorization rather than an authentication issue
TOKEN=garbage
curl -X GET "https://graph.microsoft.com/beta/groups/$TENANT/channels" -H "Content-type: application/json" -H "Authorization: Bearer $TOKEN"
Results in
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "CompactToken parsing failed with error code: 80049217",
"innerError": {
"request-id": "166cb22b-c135-45e9-9f23-0e73bc68475d",
"date": "2018-04-18T00:20:47"
}
}
}
I went here https://apps.dev.microsoft.com, logged in and created a new App. I generated a secret and stored it for later on a post-it note...
According to Create Channel Rest API document, Application type permission is not supported. So you get the error information Authorization has been denied for this request.
Delegated permissions are used by apps that have a signed-in user present. For these apps either the user or an administrator consents to the permissions that the app requests and the app is delegated permission to act as the signed-in user when making calls to Microsoft Graph. Some delegated permissions can be consented to by non-administrative users, but some higher-privileged permissions require administrator consent.
As Wajeed - MSFT mentioned that you could use Graph explorer with your account login to have a try.
Note: APIs under the /beta version in Microsoft Graph are in preview and are subject to change. Use of these APIs in production applications is not supported.

Postman Twilio Rest Api

Hi I was wondering if someone could help me ,I am trying to use twilios' rest api and im running into some trouble. MyAccountIdSid,mySid and phone numbers are filled in in the actual request,Is there something i am doing wrong,
I get Your "AccountSid or AuthToken was incorrect" .
Can someone show me the correct way to make this request for sending an sms please.
I am trying to send a text message
Post Request Url i am using :
https://api.twilio.com/2010-04-01/Accounts/MyAccountIdSid/Messages.json
{
"account_sid": "MyAccountIdSid",
"api_version": "2010-04-01",
"body": "HelloWorld",
"num_segments": "1",
"num_media": "1",
"date_created": "Wed, 18 Aug 2010 20:01:40 +0000",
"date_sent": null,
"date_updated": "Wed, 18 Aug 2010 20:01:40 +0000",
"direction": "outbound-api",
"error_code": null,
"error_message": null,
"from": "+353xxxxxxxx",
"price": null,
"sid": "mySID",
"status": "queued",
"to": "+353xxxxxxxxx",
"uri": "/2010-04-01/Accounts/MyAccountIdSid/Messages/mySid.json"
}
Twilio developer evangelist here.
If you're copying it from here, be aware that the first part of it is the request, and the second is the response, so what you're trying to send to Twilio is the response, hence why it's not working for you.
What you need to send to Twilio is the following:
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json \
-d "Body=Jenny%20please%3F%21%20I%20love%20you%20<3" \
-d "To=%2B15558675309" \
-d "From=%2B14158141829" \
-d "MediaUrl=http://www.example.com/hearts.png" \
-u 'AC36b9a6be2f98274fe61d15b63aabf1e0:{AuthToken}'
I've created a quick screeencast showing you how to do that with postman 2. Hope it helps you.
Note : Enhancement of Marcos Placona's Answer
In the Authorization section, set 'AUTH TOKEN' in 'password' field.
You can find 'AUTH TOKEN' just below Account Summary.
https://www.twilio.com/console
https://www.twilio.com/docs/api/errors/20003
'Authenticate using your Account SID as the username, and your Auth Token as the password.'