Get Google Ads customer id via login - javascript

I use “google-ads-api” to manage google ads. And api needs “customer_account_id” to initialization. However, I Couldn’t found how to get “customer_account_id” programmatically from user.
I used “react-google-login” in front-end, but there is no “customer_account_id” in the response. What is the best way to get customer_account_id?

You'll have to use the CustomerService's ListAccessibleCustomers method. This request does not require a customer_account_id and you can use it to obtain all Google Ads account IDs that the authenticated user has access to.
See the documentation for details.
I believe that in google-ads-api the relevant class is called AccessibleCustomersService.

Related

Login Email with Google to Specific Domain Name

I am not able to find any documentation on how to restrict the login to my web application to only accept authentication requests from users with an email on a specific domain name or set of domain names. I would like to block as opposed to blacklist.
Does anyone have any document or template which how to achieve using jsp,angularjs,javascript, documentation on the officially accepted method of doing so, or an easy, secure work around?
For the record, I do not know any info about the user until they attempt to log in through Google's OAuth authentication. All I receive back is the basic user info and email.
You can use method of string class String. contain("#yourdomain") it will return boolean value true or false
It will go like..
if(request.getParameter("email").contains("#yourDomainName"))
Do something;

Determine if current user has write access for google sheet

I am using Google Sheets API from a Javascript application.
Users log in to my app and grant it permission read/write permission to google sheets.
I have hardcoded a document ID for a google sheet into my application.
I want to be able to make a rest query to determine the current users access rights to that particular document. The user may have:
no access
read only access
read write access
(I manually share the relevant access to the document to each user)
I am looking for a way of doing this. I have searched the sheets API and the drive API but I can't find any call.
At the moment I plan to create a function which will:
try and read the document - if I get an error return "NO ACCESS"
try and write the document - if I get an error return "READ ONLY"
return "READ WRITE"
It seems like a bad idea to determine write access by actually making a write to the document.
Does anyone have any better ideas?
I have tried listing the permissions using this API:
https://developers.google.com/drive/v3/reference/permissions/list
but I just get a list of permissions and this has to be parsed. Also my test read only user got forbidden.

Twitter JS API, update status

I'm at a total loss here. I believe I'm right in thinking there is no longer any JS API for twitter which just sucks hugely.
However I realise looking at this I could just use ajax and react to the responses from this:
https://dev.twitter.com/rest/reference/post/statuses/update
OAuth Signature Generator
Example Request POST
https://api.twitter.com/1.1/statuses/update.json?status=Maybe%20he%27ll%20finally%20find%20his%20keys.%20%23peterfalk
However when I post to that url I get the following:
{"errors":[{"code":215,"message":"Bad Authentication data."}]}
Bad Authentication data -> this is very self explanatory: Your Authentication is Bad; in other word, you are not authorized to use that API method.
Since you use POST method, make sure you set your APP access level to Read & Write.
Sign in to apps.twitter.com, and in the Applications Management page for your app, click the Permissions tab. There you can change your access level.
For further reading, please see this answer.

Get user name with Youtube Data API 3.0

Hi I'm trying to get the youtube user name and the thumbnail with a youtube app. I´m using the v3.0 and the javascript library.
I'm following this example and docs:
https://developers.google.com/youtube/v3/code_samples/javascript
https://developers.google.com/api-client-library/javascript/reference/referencedocs
I don't have problems with the autentication but I don't know how to get de user name and image.
Somebody knows?
You can call channels->list with "part=id & mine=true"
GET https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&key={YOUR_API_KEY}
Id is the channel's ID.
You can get the channel's title from response under snippet.title. This is what you need as usernames are not useful anymore.
From snippet.thumbnails.(key), you can pick the default, medium or high resolution thumbnail, and get it's width, height and URL.
This is what you are looking for to greet, but if you want to go deeper you can check if that account is linked with Google+ and use googleplususerid to retrieve more information via Google+ API.
https://www.googleapis.com/youtube/v3/channels?part=id&mine=true&access_token = [YOUR TOKEN]
YOU MUST get Oauth code and exchange it for Access Token, to :( complex to give you full answer HERE
Here's how I had to modify my requests to make it work with authentication (otherwise I kept getting a "dailyLimitExceededUnreg" error in the response):
Don't include the "key={YOUR_API_KEY}" in the URL.
Instead, add a HTTP header "Authorization: Bearer {ACCESS_TOKEN}"

How to use my long (60day) access token to get user data from facebook (offline)

I cannot find any example on facebook dev. or here on stackoverflow so I need to make this post which i didn't thought i had to.
I have a website which uses the facebook JavaScript SDK to login users into it.
When I log in users I uses the
FB.login(), scope:{'email, offline_access'}
When the login in done i get the short lived access token and passes it to:
https://graph.facebook.com/oauth/access_token?
grant_type=fb_exchange_token&
client_id=APP_ID&
client_secret=APP_SECRET&
fb_exchange_token=SHORT_LIVED_ACCESS_TOKEN
So i get the long lived, 60day, token in response. This is done server-side and i save the new long lasting token in my database along with facebook id etc.
Now to my problem. Every day at a certain time I want to update the users data in my database using the access token, which i have read that could. But how do i do that?
I'm used to do like this after the FB.login() but now when the user do not login I don't know how to do the call to FB.api using my persisted token?
FB.api(/me....)
Regards,
Kristoffer
As you have to synchronize/update information when user is not logged in you will have to use server side interaction.
You may use your saved Extended Access Token and set it into Facebook PHP SDK using setAccessToken() method.
$facebook->setAccessToken($extended_access_token);
After this you may call $facebook->api(...) method to perform the task that you intend to.

Categories

Resources