dv360: Installed App or Server to Server application? - google-cloud-platform

I am trying to create a python script to ingest data into dv360. Its a script that just runs - its not a web app for instance. Thus I would assume its defined as a "server to server" application. Though its really a script to server application - is my computer the server in this case?
And thus I think I should be authenticating with a service account. But all the documentation I can find recommends using oauth2 for dv360 instead of a service account. Even inside of oauth2 I see that there is a delineation between installed oath and server to server oauth.
Can anyone who has experience with the dv360 api tell me what my application described above would be classified as and whether I need a service account, oath for installed apps, or oath for server to server apps in order to authenticate?

For your use case OAuth 2.0 for Server to Server Applications is recommended.
You can use Google API Python Client library to perform operations on DV360 using service account.
Here is the sample snippet to fetch DV360 Advertisers using this python client library.
import json
from googleapiclient import discovery
# DV360 service
dv360_service = discovery.build('displayvideo', 'v1')
# Get Advertiser Info
data = {'advertiserId': '1234567'}
response = dv360_service.advertisers().get(**data).execute()
print(json.dumps(response, indent=2))
Output:
{
"name": "advertisers/1234567",
"advertiserId": "1234567",
"partnerId": "8901234",
"displayName": "LoremIpsum",
"entityStatus": "ENTITY_STATUS_PAUSED",
"updateTime": "2022-10-14T04:46:31.291Z",
"generalConfig": {
"domainUrl": "https://www.example.com",
"timeZone": "Asia/Calcutta",
"currencyCode": "INR"
},
"adServerConfig": {
"thirdPartyOnlyConfig": {
"pixelOrderIdReportingEnabled": true
}
},
"creativeConfig": {},
"dataAccessConfig": {
"sdfConfig": {
"sdfConfig": {
"version": "SDF_VERSION_5_2"
}
}
},
"integrationDetails": {},
"servingConfig": {
"exemptTvFromViewabilityTargeting": true
}
}
Make sure to set GOOGLE_APPLICATION_CREDENTIALS environment variable with path/to/service-account-key.json before running the script
e.g. GOOGLE_APPLICATION_CREDENTIALS='/home/dikesh/.keys/service-key.json' python test.py

Related

Where to deploy Strapi backend and use it with Nuxt frontend?

I have a Nuxt frontend deployed to Google App Engine.
Can I deploy Strapi to Netlify? Or is there a platform where I can deploy Strapi for free?
Also after deploying what is the exact setting which needs to be changed in Nuxt?
My settings with apollo.
apollo: {
clientConfigs: {
default: {
httpEndpoint: 'http://localhost:1337/graphql',
},
},
},
#nuxtjs/strapi Settings in Documentation.
modules: ['#nuxtjs/strapi'],
strapi: {
entities: ['restaurants', 'categories'],
url: 'http://localhost:1337'
},
I guess I have to place the Heroku URL in place of localhost:1337 if I use #nuxtjs/strapi which I am not using currently?
What if I want to use apollo? Where should I put the Heroku URL as it has httpEndpoint field for graphql URL?
Strapi needs a Node.js server, so Heroku is a good idea. They do have a free tier dyno that takes some time to spin up but there is no issue since you will use it as a headless CMS.
Once deployed, you'll need to update the URL of Strapi in nuxt.config.js. And I guess that it's pretty much all.
You will have all of your info in their official docs: https://strapi.io/documentation/developer-docs/latest/setup-deployment-guides/deployment/hosting-guides/heroku.html

React Native Expo / Deep Linking / Universal Link

I am building app using react native, Expo SDK - 41 & react-native-navigation - v5 that serves items to the users
How can I create links to be shared between users through social media apps like "WhatsApp" or "Facebook" as messages
For Example:
I found this item on "App Name". Take a look, https://myApp/itemId
When the user press the link it will open the app on specific screen to show that item (if the app installed on the receiver device), Otherwise will open the App store (Android or IOS) depend on the device to download and install the app.
And is there is any tutorial that explain the whole implementation for this feature ?
Here are the steps I used in our app:
For the steps below let's assume you own a domain https://example.com and you want to redirect all clicks on https://example.com/your-path/ to:
redirect to the app/play store if the app is not installed
opened in the browser if on a desktop device
open the app on iOS/Android if app is installed
Steps to achieve that:
You need a domain (e.g. https://example.com)
Registering Universal Links on iOS:
You have to prove to Apple that you own this domain by providing an Apple App Site Association (AASA) file from your web server.
Detailed explanation: https://docs.expo.dev/guides/linking/#universal-links-on-ios.
Note: No server-sided configuration needed for Android
After that you need to configure the domains (you specified in the AASA) in your expo app.json file (See: https://docs.expo.dev/guides/linking/#expo-configuration)
Note: The Expo docs don't show any example so I'll share one:
"expo": {
"name": "MyApp",
...,
"ios": {
...,
"associatedDomains": [
"applinks:example.com"
]
},
"android": {
...,
"intentFilters": [
{
"action": "VIEW",
"autoVerify": true,
"data": [
{
"scheme": "https",
"host": "*.example.net",
"pathPrefix": "/your-path"
}
],
"category": [
"BROWSABLE",
"DEFAULT"
]
}
]
}
}
}
Result of the steps above: if you click a link like https://example.com/your-path/ (or any subdomain of that e.g. https://example.com/your-path/your-second-path?hello=world ...),
you should be redirected to the app on iOS/Android if the apps are installed.
However if the app is not installed a browser widow opens https://example.com/your-path/
Redirecting to app stores:
You have to configure the subdomain .../your-path in a way to check which device is trying to open it when loading the site and redirect to the app store/play store - url if it is an iOS/Android device resp.
Example: in our case the domain leads to a React web app and on loading the page ( on componentDidMount ) I check User's device using navigator.userAgent
This will of course differ from framework to framework.
Here you can also choose what to show or where to redirect if the link is clicked on a desktop device.
Handle links in your iOS/Android app:
Now in Expo you need to install expo-linking via expo install expo-linkingand set a listener to handle URL links in the desired component:
import * as Linking from 'expo-linking';
componentDidMount() {
this.grabLinkOpeningApp()
this.setLinkListenerWhenOpeningApp()
}
grabLinkOpeningApp() {
//Handles link when the link is clicked and the app was already open
Linking.addEventListener('url',this.handleUrl)
}
setLinkListenerWhenOpeningApp() {
//Handles link when app is closed:
Linking.getInitialURL()
.then(url => this.handleUrl(url))
.catch(err => this.handleError(err))
}
handleUrl(url) {
//Handle your link here
}
Note: Best to use the code in a component that is opened before the actual screen components. In this case you can catch the link no matter if the user is registered or not and like that it can "survive" the registration process.
7. Create a link and share it from your app:
You can add arbitrarily many query params to the link, i.e. .../you-path/key1=value1/key2=value2....
So you can create links within your app using data however you need it for your specific use case.
If you want to share the link via the typical share dialog where the user can choose the app you he wants to share the link with (i.e. Whatsapp, Facebook, Instagram, etc.), you can either import {Share} from 'react-native' or import * as Sharing from 'expo-sharing'
(see resp. expo docs, this part is very straight forward following the docs)
In the end, sorry for the long text, but I hope it explains the steps involved well.

Vue AWS Amplify fail to get credentials

i am using AWS Amplify for authentication in a Vue app.
i am able to login successfully but cannot get credentials using Auth.currentUserCredentials() and Auth.currentCredentials().
i'd appreciate any help to sort out the problem.
i use Amplify's Hub event listener to listen to the auth channel for authorization events and the logger to debug.
on signing in, i notice this:
this is running in developer mode but exact same errors appear if built and run on website.
it seems that a POST to the localhost is causing the problem. but why does it call localhost when running a production build?
here's the whole log from signing in until after calling Auth.currentCredentials():
here's the code for the login form:
<amplify-authenticator>
<div>
My App
<amplify-sign-out></amplify-sign-out>
</div>
</amplify-authenticator>
here's my aws-exports.js file:
const awsmobile = {
"aws_project_region": "eu-west-1",
"aws_cognito_identity_pool_id": "eu-west-1:xyz....-4144-4b70-b021-e3486dbb1d43",
"aws_cognito_region": "eu-west-1",
"aws_user_pools_id": "eu-west-1_xyz....",
"aws_user_pools_web_client_id": "xyz....",
"oauth": {}
};
export default awsmobile;
seems there was a bug which has now been fixed so working now

How to connect to ElasticSearch on AWS via reactivesearch-proxy-server

I'm setting up my first ElasticSearch app using ReactiveSearch to connect to an ElasticSearch index I created on AWS.
I'm new to Node.js and most of the technology involved here. I think I have a basic ReactiveSearch app that works but it won't connect to my AWS ElasticSearch index. When I enter a search I get no output and no errors.
I followed the ReactiveSearch Quickstart guide:
https://opensource.appbase.io/reactive-manual/getting-started/reactivesearch.html
I created the Boilerplate App with CRA:
https://github.com/facebook/create-react-app#creating-an-app
The app runs ok but there is no output when I try to search.
Then I saw the note that you have to use a proxy with AWS. I cloned https://github.com/appbaseio-apps/reactivesearch-proxy-server and got that working and I now have a proxy that runs on http://localhost:7777/
My Search App connects to the proxy like this:
<ReactiveBase
app="my-search"
url="http://localhost:7777">
This is the code that sets the target in the proxy. I commented out the authorisation because I'm not using appbase.io.
const options = {
target: 'https://search....ap-southeast-2.es.amazonaws.com',
changeOrigin: true,
onProxyReq: (proxyReq, req) => {
/* proxyReq.setHeader(
'Authorization',
`Basic ${btoa('cf7QByt5e:d2d60548-82a9-43cc-8b40-93cbbe75c34c')}`
);*/
/* transform the req body back from text */
const { body } = req;
if (body) {
if (typeof body === 'object') {
proxyReq.write(JSON.stringify(body));
} else {
proxyReq.write(body);
}
}
}
}
I can see the ReactiveSearch app on my browser at http://localhost:3000
When I type keywords into the search box I see output like this in the proxy app:
Verifying requests ✔ {"preference":"results"}
{"query":{"bool":{"must":[{"bool":{"must":[{"bool":{"should":[{"multi_match":{"query":"cables","fields":["Description"],"type":"best_fields","operator":"or","fuzziness":0}},{"multi_match":{"query":"cables","fields":["Description"],"type":"phrase_prefix","operator":"or"}}],"minimum_should_match":"1"}}]}}]}},"size":50,"_source":{"includes":["*"],"excludes":[]},"from":0}
Verifying requests ✔ {"preference":"SearchBox"}
{"query":{"bool":{"must":[{"bool":{"must":{"bool":{"should":[{"multi_match":{"query":"horse","fields":["Description"],"type":"best_fields","operator":"or","fuzziness":0}},{"multi_match":{"query":"horse","fields":["Description"],"type":"phrase_prefix","operator":"or"}}],"minimum_should_match":"1"}}}}]}},"size":20}
What am I missing to get the connection working? Do I need to add some kind of authentication in AWS and add passwords to the proxy code?
Is there a way to see some debugging info?
Thanks,
Phil

How to reconfigure user accounts correctly while deploying meteor app using mup

I am having Facebook and Google user accounts in my meteor app. I did setup them using accounts-ui package using the nice default UI of it. But I removed the default UI and added some custom buttons. How to reconfigure the private and public keys when deploying now? I am using mup to deploy.
I believe there was something like settings.json and settings.production.json
You make mup use the latter one.
Edit: or it was settings.development.json and settings.json, the latter one is the default?
You could use a production or development settings file for deploying
your apps:
http://themeteorchef.com/snippets/making-use-of-settings-json/
meteor deploy example.meteor.com --settings setting-production.json
setting-production.json =>
{
"kadira": {
"appId": "XXXXXXXXXXXXX",
"appSecret": "XXXXXXXXXXXXXXXXXXXXXXX"
},
"reCaptcha": {
"secretKey": "XXXXXXXXXXXXXXXXXXXXXXX"
},
"public": {
"reCaptcha": {
"siteKey": "XXXXXXXXXXXXXXXXXXXXN"
}
}
}