Creating a Facebook Ad Account Sandbox account and unlocking ads_read - (AKA: Getting through the getting started tutorial from facebook) - facebook

I apologise in advance if this question has been asked elsewhere or if it's a stupid question, but I'm desperate!
My goal
Create a POC which connects to a facebook sandbox ad account and tests what features are exposed in the API, such as uploading new video ads or creating ad campaigns.
The problem
I am following facebooks own getting started example for connecting with nodejs:
https://developers.facebook.com/docs/business-sdk/getting-started/#js
When i try to read from the AdAccount i get the following error:
(#278) Reading advertisements requires an access token with the extended permission ads_read
Under Marketing API -> Settings, it is possible to submit a request to be granted access. I think..? This part confuses me a lot.
In order for me to grant my access token the right to make calls requiring the ads_read permission, a human person at facebook must first grant me the right to grant this right to my access token?? (Please tell me if I got this wrong, it feels like that has to be wrong).
Chicken and the Egg?
As part of this proces i have to provide detailed instructions on reproducing the required need for permissions and a screencast of the process.
However all i have at this point is the sample code provided by facebooks example. And i don't plan on developing anything for this until i can at least get their sample working, which i can't without being granted access to ads_read it would seem.
I must have misunderstood something
It seems obvious that i must have misunderstood something, but what?
Am i not supposed to follow the example from facebook called getting started? I that not the right example for getting started?
Or am I trying to unlock the permission in the wrong place?
Is the error just misleading?
Or should i just complete the submission steps for ads_read and provide an empty screencast and say I'm just getting started?
Any help, clues, or link to guides that address this issue would be greatly appreciated. (Again i apologise if this question is very basic but I'm at the end of my rope here, thanks in advance)

In case anyone else is having the same problem i was, I feel it's appropriate to post how I managed to get the right token.
First off there is nothing wrong with the tutorial code here:
https://developers.facebook.com/docs/business-sdk/getting-started/#js
The hard part is to find the right token and give it access to make the calls used in the tutorial.
Assuming that you already have managed to create a Sandbox Ad Account you need to connect it to your business account here:
https://developers.facebook.com/apps/[APP-ID]/marketing-api/tools/?business_id=[BUSINESS-ID]
On this page there should be 4 buttons next to where the sandbox account is listed. One of them is a key with the caption "Get Access Token". This is the WRONG access token. (If anyone can elaborate on how/why please feel free).
In order to get the access token you need to run the "Getting Started" sample you will need the ads_read permission.
Among the 4 buttons there should also be a suitcase with the caption "Connect to Business". If you do not see this button it either means you have no business or that you haven't attached a system user to your business (I think).
If the button is not there
Go to: https://business.facebook.com/settings/system-users?business_id=[BUSINESS-ID]
Create a system user and connect it to your App. Don't forget to set the permissions for that user.
If the button is there
Click the button and select your system user in the dropdown.
Then go to:
https://business.facebook.com/settings/system-users/[SYSTEM-USER-ID]?business_id=[BUSINESS-ID]
And click the Generate New Token button. Again don't forget to set the permissions for the token.
It may seem like a silly issue but it cost me almost a whole day myself so hopefully this could save someone else the time.
EDIT: I came across an access token debugger which could prove helpful to others with access token problems:
https://developers.facebook.com/tools/debug/accesstoken/

Its in your app tools at the url https://developers.facebook.com/apps/APPID/marketing-api/tools/
If you don't have an app, create a test app

Related

How to make a Facebook Test Page have an Instagram Business account?

When you're trying to apply for Facebook Permissions for your application, you may encounter some permissions that requires App Review. In my case, I need to use the Facebook Login for Business Accounts, so I need to apply for Facebook's App Review.
In order to make an App Review for Facebook, you will need to provide step-by-steps videos and guides for Facebook testers to test for themselves. However, it does requires a Test User to do this.
A Test User can have a Test Page linked to it, and a Test Page is capable to link an Instagram Account created using this Test User. However, for some reason, I'm not able to convert this created Instagram Account as a Business Instagram Account using the Test User. I tried to link it using my application flow, but the "Convert to Business Profile" button does nothing, and if I try to do this in the Facebook Test Page account, the form that ask for Contact Information always throws a message "An Error Ocurred".
So, I'm unable to create an Instagram Business for testing and also not allowed to provide a real account because they don't allow this, as they explicitly says (Which I can agree with):
Note: Do not provide your personal Facebook account credentials.
As I'm unable to find a way around this, and I can't see to find any answer on the internet... I wonder if somebody could help with this one.
So, it seems it's just a Facebook bug (Just as one I was experiencing before this one, where after updating a Test Account permissions, the permissions were still not working properly) where the Test Account seems to be kind of locked in a state were you can basically do nothing more with it than what you have already done... So I end up creating a new Test Account and doing the same process, but this time it worked.
I had the same problem, and to fix it, I had to follow these steps :
Create a Facebook test user for your app.
Once the user has been created, click the three dots at the right, then edit its password, choose something that you will remember.
login as this test user.
Edit the user parameters and set its email address as main/default contact address (you need to type in the password of the user). It seems, by default, test user do not have default contact and this is required to login with instagram.
Now go to instagram.com, and create a new account using "login with facebook"
Fill in the name, password (you need to remember it), and userid.
Send the form, and you will get some error telling you to retry later. Ignore it, your account should actually be created.
Now switch to the instagram mobile app (web interface might not work, I was stuck in a redirect loop) so you can login to instagram using the email address of the facebook test user account (the one you used in point 4) and the IG password (you typed in point 6).
Hope it helps anyone stuck in this hell like I was for 2 days.

Facebook account linking, can anyone give small example code?

I'm very frustated, I can't figure out how to link accounts using the account_link button, it's making my life so hard, I posted this question before, and I thought I had understood how but I just didn't, it's driving me crazy.
Can someone please post a sample code of how to achieve this?
You get on you account linking url the GET parameters:
$token = $_GET['account_linking_token'];
$uri = $_GET['redirect_uri'];
Then you type in your credentials in the log in.
User: user
Password: pass
Click login.
You go and verify credentials, if they are correct, you link the account:
THIS IS THE SMALL BASIC EXAMPLE CODE I NEED
Then, if account linked succesfully, I redirect to the uri:
redirect($uri.'&authorization_code=myauthorizationtoken');
After this, I can retrieve PSID with the API.
Can somebody help me out please?
Check this out : Account Linking Failed
Use messaging_account_linking subscription for your Facebook developer application.
Your problem is that you do not understand what account linking really means. Account linking means that you should ask this current messenger user to login on your platform thereby linking the messenger account to the user account on your platform.
The flow is just an implementation of OAUTH 2.0. Please read it up to really understand what's going on.
Your job is to just
Redirect the user to a login screen on your part and get the user's PSID using the endpoint provided by the documentation.
Save the PSID and (optional) account linking token to the user's data model.
Generate an authorization code(this is part of the OAUTH 2 flow)
Redirect back to messenger.

OAuthWebSecurity Facebook ominous message: app "would like to access your public profile, friend list and email address"

Using the asp.net-mvc4 oauth Facebook client (OAuthWebSecurity.RegisterFacebookClient) pretty much as it is in the MVC4 template internet app. Problem is, when users log in with their account they see the message:
"would like to access your public profile, friend list and email address"
The thing is, I don't want access to their public profile, friend list and email address. I just want to allow them to log into my app using their Facebook account. I can see that this message would turn people away (I personally wouldn't click 'okay').
Ideally, I would like to specify the level of permission required in my MVC app where the mimimum level does not result in that message. This would allow increased privilege at a later stage if needed. But, I would settle for any way that I can get a less ominous message.
I have looked at the settings in the Facebook app management page, but can't see anything that would reduce the restrictions. I tried configuring the permissions to only-me, but this didn't help. I searched online and did not find anything that suggested a solution to this.
Any help would be great.
Edit:
Also, I am not sure why 'public profile' is mentioned in the message at all. Can't anyone access your public profile (since it is public)? So why mention it in the message? Or does the word 'access' mean more than simply being able to see the public profile?
Those are the very basic permissions that a user grants you by just logging in to your app - has always been that way, FB have just updated the message shown to the user to make it more clear what they actually share.
You can not ask for "less" permissions.

ASP Classic: twitter and facebook autoposting without signing in

In work I got a task (we MUST work with ASP Classic by the way): when user posts a blog, a link to that blog should be posted automatically on user's facebook timeline and in his twitter. I made everything working, but there is one problem: user needs to be signed in to post. I've made the cheking if he's logged in, and if not he must log in.
But I need to avoid the logging-in step and make it automatic (by sending user's username and password as part of the data sent to twitter/facebook or something like that), but I can't figure out how to do that or if it's even possible at all.
Any ideas? Would greatly appreciate any help.
P.S.: for the twitter part I used http://scottdesapio.com/VBScriptOAuth/
for the facebook part I used a combination of: http://snipplr.com/view/61108/facebook-app-login--authorization-entirely-clientside/
Everything works, but is it possible to automatize the user's sign-in part?
Finally I managed to make the both things automated...
The problem with Twitter was that I didn't store request token in session, that's why I got "Could not authenticate you" error.
Can't remember what I did wrong with Facebook (some co-workers helped me out), but I guess I didn't make proper http requests...
So the answer is: yes, it is possible to automatically post to Twitter and Facebook without user sign in.
If I am not wrong then your logged in user in facebook for current browser is not authorize for your app.
I think you should try googling about "How to authorize users into app". OR
If you don't mind I am giving you the direct URL to go to that setting page for your app:
https://developers.facebook.com/apps and then go to your app then after from left side bar go to roles and then after click on test user tab from top of page and then click on add button it will opne one pop-up to add a user.
In app you have to add test user for testing purpose and have to login for that added test user, so added user will be authorize for that app and you will be able to test.
Thank you...

Asking for new permissions once the app has been authorised using Javascript SDK

I have users who have authorised my app and are using it. I now need to request further permissions on top of this and I remember reading that the Javascript SDK has some inbuilt methods which allow you to just request the permissions which have not already been handed over. I've looked around a fair bit but I can't find any information on this anymore.
Can someone confirm that this exists, and if possible, how I can do this? I actually switched from using the PHP SDK for the login just because I read about this feature!
You can actually do this in the php-sdk as well. What you need to do is inspect the permissions connection and see if the user has granted the required permission to your app
https://developers.facebook.com/docs/authentication/permissions/
If not you can either redirect them to the auth dialog, or prompt them with a button and explain why you want them to authenticate again.
You can view a sample response at
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fpermissions
Alternatively,using the Auth Dialog
https://developers.facebook.com/docs/opengraph/authentication/
might also achieve what you are after, though this only works on referrals from Facebook I believe
It's the same procedure as with users who have disconfirmed a permission. In that case the documentation for invalid access tokens applies: https://developers.facebook.com/docs/authentication/access-token-expiration/
So, you just need to reauthenticate the user including the additional permissions in the scope parameter.
You should be able to check for granted permissions, then if they are not the same as the ones you need then just redirect them to log in with he extended permissions you require and that's it.
http://developers.facebook.com/docs/reference/fql/permissions/