tophatter / facebook-ruby-ads-sdk

The Facebook Marketing API in Ruby.
https://developers.facebook.com/docs/marketing-apis
MIT License
62 stars 39 forks source link

Can't use multiple credentials due to access token having global state #28

Open kurko opened 6 years ago

kurko commented 6 years ago

By having

FacebookAds.access_token = '[YOUR_ACCESS_TOKEN]'

we aren't able to manage multiple accounts on behalf of our clients because the .access_token set its value as a global state, at the class level.

Ideal way would be instantiating FacebookAds with the access token, e.g

client1 = FacebookAds.new(access_token: '[ACCESS_TOKEN1]')
client2 = FacebookAds.new(access_token: '[ACCESS_TOKEN2]')

Is there a workaround with the current code? Or any suggestion on how to proceed?

Thanks a lot.