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

Multiple applications per executable #101

Closed
alex-netkachov opened this issue Sep 19, 2015 · 6 comments · Fixed by #222 · May be fixed by #182
Closed

Multiple applications per executable #101

alex-netkachov opened this issue Sep 19, 2015 · 6 comments · Fixed by #222 · May be fixed by #182

Comments

@alex-netkachov
Copy link

Hello,

While making the twitter bot I realise that I should have to call two applications, e.g. use different application keys at the same time. It looks like the anaconda currently does not support it. I do not mind try to do it myself, but do you maybe have design considerations about it?

Regards,
Alex

@ChimeraCoder
Copy link
Owner

Alex - would you be able to elaborate a bit further on your use case? What are you writing that needs to use two different sets of consumer keys (as opposed to access tokens, which are user-specific)?

@ghost
Copy link

ghost commented Jan 11, 2016

What about this? Should work.

// App #1
anaconda.SetConsumerKey("your-consumer-key")
anaconda.SetConsumerSecret("your-consumer-secret")
api := anaconda.NewTwitterApi("your-access-token", "your-access-token-secret")

// App #2
anaconda.SetConsumerKey("your-consumer-key")
anaconda.SetConsumerSecret("your-consumer-secret")
api2 := anaconda.NewTwitterApi("your-access-token", "your-access-token-secret")

Now you should have access to both apps.

@dougnukem
Copy link

seems like you should be able to specify all the keys in the NewTwitterApi instead of relying on global state e.g. you can't reliable do this across multiple goroutines.

Imagine you had a multi-tenant server handling multiple twitter apps and user authentication (e.g. social-media marketing campaign CMS or something).

# Add new client through some HTTP request in it's own go routine (to simulate a pool of go routines in an http handler, or maybe it's a message queue handler etc)

go func() {
    // App #1
    anaconda.SetConsumerKey("your-consumer-key")
    anaconda.SetConsumerSecret("your-consumer-secret")
    api := anaconda.NewTwitterApi("your-access-token", "your-access-token-secret")
}()

# Simultaneously you have another request
go func() {
    // App #2
    anaconda.SetConsumerKey("your-consumer-key")
    anaconda.SetConsumerSecret("your-consumer-secret")
    api := anaconda.NewTwitterApi("your-access-token", "your-access-token-secret")
}()

It seems like it should just be:

    api := anaconda.NewTwitterApi("your-consumer-key", "your-consumer-secret", "your-access-token", "your-access-token-secret")

@mchusovlianov
Copy link

Yeah, it would be great. It's a really pain when you want to use anaconda in multiple routines.

@mmcdole
Copy link

mmcdole commented Jan 30, 2017

I've ran into this issue as well and found myself really wishing ConsumerKey and ConsumerSecret were part of the constructor, not a global variable.

@a-chernykh
Copy link

Yeah, I am having the same use case here - need to create multiple TwitterAPI instances pointing to different Twitter Applications. PR #182 seems to be solving this problem.

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