facebook / facebook-nodejs-business-sdk

Node.js SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
489 stars 226 forks source link

No permission to access this profile getGeneratePreview() error #268

Open spiritcoder opened 9 months ago

spiritcoder commented 9 months ago

Which SDK version are you using?

Version 18

What's the issue?

I am able to generate an Iframe from the getGeneratePreview() method on ads creative, but can't load the Iframe.

Steps/Sample code to reproduce the issue

const account = new faceBookSDK.AdAccount(adAccountId);

        account
            .getAdCreatives(['id', 'body', 'image_url', 'thumbnail_url', 'object_story_spec'], {})
            .then(async (creatives) => {
                // Process the list of creatives
                const indexdata = creatives[13];
                const creativeFields = faceBookSDK.AdCreative.Fields;

                const creativeField = Object.keys(creativeFields);
                const adCreative = await new faceBookSDK.AdCreative(indexdata._data.id).get(creativeField);
                if (adCreative._data.object_story_speclink_data) {
                    delete adCreative._data.object_story_spec.link_data.image_url;
                } else {
                    delete adCreative._data.object_story_spec.video_data.image_url;
                }
                const generatepreviewss = new faceBookSDK.AdAccount(adAccountId) as any;
                const generatepreviews = await generatepreviewss.getGeneratePreviews(fields, {
                    creative: adCreative,
                    ad_format: 'mobile_feed_standard',
                });
                console.log(generatepreviews);
            })
            .catch((error) => {
                console.error(error);
            });

Observed Results:

It returned an IFrame that we want to preview on the frontend but we can't load the Iframe. It shows

No permission to access this profile You don't have required permission to access this profile

Expected Results: