I am using Facebook graph API to create a Facebook ads campaign from Google Apps Script.
I successfully create a Campaign, I get the ID of this new campaign and then I try to create an adset associated with it, but I get the following error:
Exception: Request failed for https://graph.facebook.com returned code 400. Truncated server response: {"error":{"message":"Invalid parameter","type":"OAuthException","code":100,"error_subcode":1815430,"is_transient":false,"error_user_title":"Nessun ... (use muteHttpExceptions option to examine full response)
at createAdsets(Create:309:36)
The facebook Url I encode and then fetch is:
https://graph.facebook.com/v7.0/act_XXX/adsets?name=BlaBla&daily_budget=5000&campaign_id=YYY&bid_strategy=LOWEST_COST_WITHOUT_CAP&billing_event=IMPRESSIONS&optimization_goal=LEAD_GENERATION&targeting={"age_max":65,"age_min":25,"geo_locations":{"countries":["IT"],"location_types":["home","recent"]},"targeting_optimization":"expansion_all","brand_safety_content_filter_levels":["FACEBOOK_STANDARD"]}&status=PAUSED&access_token=ZZZ
Do you see any mistake in this UTL?
If not, can you help me see the full Truncated server response, especially the "error_user_title"?
In order to do that I have already tried:
To pass the muteHttpExceptions: true as options, but I only get the full response without being able to examine the error
To use the stackdriver with console.error method, but the "error" remains truncated.
Related
I managed to set up a developer account to get API responses working on the API explorer. However, I'm trying to connect to Postman and have been getting the following error messages.
I have gotten my user access token as follows:
The Callback URL: I have used the RuName (eBay Redirect URL name)
Auth URL: I have used https://auth.sandbox.ebay.com/oauth2/authorize (https://developer.ebay.com/api-docs/static/oauth-consent-request.html#configure)
Access Token URL: I have used the https://api.sandbox.ebay.com/identity/v1/oauth2/token (https://developer.ebay.com/api-docs/static/oauth-authorization-code-grant.html)
ClientID and Client Password I've used the credentials from my developer account
This returns the following token:
As you can see a USER ACCESS TOKEN.
When I go to use the request in an API put request I always get the following error:
The token seems to be right.
I try the same call in the built in API explorer and it works.
Please could someone advise its driving me crazy, probably something I've done wrong but any ideas?
During Authentication the following happens it prompts me to login and then shares the oath code (it doesn't tell me to accept the application as stated in document not sure why though)
I'm trying to get an authorization code from Google+ API, as described in Step 1(Set authorization parameters) (HTTP/REST).
As I've read there, the Google authorization server has the following mandatory query string parameters: client_id, redirect_uri and scope, so my href would look like this:
https://accounts.google.com/o/oauth2/v2/auth?client_id=123002756467-dmq0soo7rlfc4on640hdsehnrvb700t7.apps.googleusercontent.com&redirect_uri=http://localhost:5000/oAuthCallback&scope=https://www.googleapis.com/auth/glass.location
When trying to access that link, I get the following error:
Error: invalid_request (Required parameter is missing: response_type)
Though, the response_type parameter is not specified in that parameter list at all!
Any ideas how this can be solved?
Fixed. It seems that the spaces in my code editor were also inserted in my link as "%20", so that's why it didn't work.
Since you're following the server documentation, the response_type=code parameter is present in the sample authorization request URL in the next step [1].
You can learn more about response types here: https://developers.google.com/identity/protocols/OpenIDConnect#response-type
[1] https://developers.google.com/identity/protocols/OAuth2WebServer#redirecting
I am integrating yammer features in our app (web-front-end stack and using Yammer JS SDK). So, I want get all the groups of a login-ed user.
Inorder to get all the groups, I have tried to call the end points in two ways, /groups.json=mine using SDK - resposne showing method not authorised and www.yammer.com/api/v1/groups.json=mine=1 using normal ajax GET request- throwing access control origin issue.
API is perfectly working, while tested using google chrome browser - by disabling web security.
My question is how I can call www.yammer.com/api/v1/API_END_POINTS without cross origin issue using yammer JS SDK or any other technique?
I found an related answer in this Q & A , but still showing error for me.
Error :
XMLHttpRequest cannot load
https://www.yammer.com/api/v1/groups.json?mine=1. Response to
preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'https://xxx.dev.com' is therefore not allowed
access.
Code I have tried after login code :
1# GET Request - return $http.get('https://www.yammer.com/api/v1/groups.json?mine=1')
2# yammer JS SDK -
yam.platform.request({
url: "groups.json?mine=1",
method: "GET",
success: function (group) {
console.log(group);
},
error: function (group) {
console.error("There was an error with the request.", group);
}
});
I have already commented different Q&As for the opinion, but no luck, no one replied.
PS - My all other yammer APIs are working(login, post, message etc), which listed in Yammer REST API Docs, only I am facing problem with APIs hosted in wwww.yammer.com/api/v1, Not api.yammer.com
Thanks in advance
You should register an App in Yammer dev console, specify allowed origins, get an API key and send it along with request.
See https://developer.yammer.com/docs/api-requests for more info.
I need to make an http request to Twitters REST API and obtain statuses containing a certain word like "#javascript".
I looked at the docs and tried this request:
https://api.twitter.com/1.1/search/tweets.json?q=#javascript
But I got the error: "Bad Authentication data."
Can anyone tell me how to make this request correctly?
It appears that Twitter require an authentication token for you to use their search api. See this page https://dev.twitter.com/rest/public/search
Check this page for what you will need, and how to set it up
https://dev.twitter.com/oauth/overview
I Had the following code
$client->setClientId('39605174446-s067746s1jur731n49fujigfh8occ5pa.apps.googleusercontent.com');
$client->setClientSecret('MYCLIENTSECRET');
$client->setRedirectUri('http://examplesss.com/oauth2');
$client->setScopes('https://picasaweb.google.com/data');
$client->setAccessType("offline");
I did authenticate
At my Google Console API, I set it for "Web Application", Authorization Javascript origins I leave it blank.
Authorization Redirect URI I set it as
http://example.com/oauth2
I went to the following site to get my authorisation code
https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=&client_id=39605174446-s067746s1jur731n49fujigfh8occ5pa.apps.googleusercontent.com&redirect_uri=http://example.com/oauth2&response_type=code&scope=https://picasaweb.google.com/data&state=state
When I went into the site, I press ok to grant "offline access" . After that I am redirect to an none existent site which I use that is example.com and then the URI was something like
http://example.com/oauth2?state=stat&code=4/qWt9q19VtilG6Iw6HFte4RnpiXR0a5q80_zQAU-hNqc#
$client->authenticate('4/qWt9q19VtilG6Iw6HFte4RnpiXR0a5q80_zQAU-hNqc#');
Then I get my refresh token code
$client->refreshToken('1\/vYnZlRcvaY2nD0yh5LhU9paLZZggMArGOo-3rEJHGCM');
But when I run the code it say...
PHP Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: '{
"error" : "invalid_grant"
Wonder what went wrong, I just want to access my picasa web album.
Thanks
It can be 2 things. One, is the incorrect use of the versions of the Google API client or the one I think that is the problem, it's on the refresh token and how you're passing the token. It's a problem with the / character in the string, json enconding and how it's passed. Put the refresh token in double quotes and send the variable. If all the data is correct and authorized via Google, it should work.