Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdUser.get_ad_account doesn't flow api instance to AdAccount #66

Closed
dylanlingelbach opened this issue Jun 9, 2015 · 8 comments
Closed

Comments

@dylanlingelbach
Copy link

When I create an AdUser with a specific api instance and then call get_ad_account on that instance the api instance does not flow to the created AdAccount.

Here is a test case that reproduces this issue:

    app_id = config['app_id']
    app_secret = config['app_secret']
    access_token = config['access_token']
    def test_get_ad_account_from_ad_user():
        assert FacebookAdsApi.get_default_api() == None # Ensure the default api is not set
        session = FacebookSession(
            app_id,
            app_secret,
            connection.access_token,
        )
        api = FacebookAdsApi(session)
        me = AdUser(fbid='me', api=api)
        ad_account = me.get_ad_account()
        assert ad_account.get_api() == api
@dylanlingelbach
Copy link
Author

This seems to be more general than the specific case I have above. It seems like any call that creates an object does not flow the api instance.

I am using version 2.3.3 of this library.

@ebzlo
Copy link

ebzlo commented Jun 19, 2015

Hey @dylanlingelbach, we don't flow the api object in the manner you're describing (but that might be a good PR). The flow you're using would require the following call after you instantiate the FacebookAdsApi object:

api = FacebookAdsApi(session)
FacebookAdsApi.set_default_api(api)

Alternatively, you can skip creating the session and creating the FacebookAdsApi object by doing the following:

api = FacebookAdsApi.init(app_id, app_secret_access_token)
me = AdUser(fbid='me', api=api)
ad_account = me.get_ad_account()
assert ad_account.get_api() == api

@ebzlo ebzlo closed this as completed Jun 19, 2015
@ebzlo ebzlo reopened this Aug 18, 2015
@wpromatt
Copy link

@ebzlo Then why does the readme documentation say that using multiple access tokens is supported and the only area where you have to again pass the api instance is with class methods?

From here, all the following workflow for these objects remains the same. The only exceptions are the classmethods calls, where we now should pass the api we want to use as the last parameter on every call.

@JDaance
Copy link

JDaance commented Feb 18, 2016

I vote that the API should flow to all fetched objects!

How would I set the api on the fetched objects afterwards as it is now? I can't use set_default_api as I have many users at the same time.

@dylanlingelbach
Copy link
Author

@JDaance: you can use our forked version: https://github.com/Evzdrop/facebook-python-ads-sdk

We try to keep it up to date and have a few other changes there but should get you pointed in the right direction.

Hope this helps!

@dylanlingelbach
Copy link
Author

@rituparnamukherjee - was this fixed or no longer an issue in later versions of the SDK? Or are you saying you aren't going to fix this?

@rituparnamukherjee
Copy link
Contributor

@dylanlingelbach

Apologies for confusion. We have updated quite a bit on the SDK. Would you mind sending out a PR for this off of the latest SDK version.

@dylanlingelbach
Copy link
Author

@rituparnamukherjee - ok, our solution is not ready for a PR, it is a pretty quick hack. Can we leave this open until you fix or we open a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants