mercadolibre / ruby-sdk

MercadoLibre's Ruby SDK
25 stars 35 forks source link

AUTH_URL is always set to ML Brasil #10

Open lubc opened 8 years ago

lubc commented 8 years ago

It seems that it's not possible to dynamically change the auth_url setting because it's always using the value in config.yml.

I’m using this gem in an application with users from different countries (AR, CL, MX, CO), so I have one ML app for each of those countries.

But after running meli.auth_url(callback) it never works because auth_url is always pointing to Brasil, and none of my ML Applications are from there.

$ meli_client.auth_url(callback)
=> "https://auth.mercadolivre.com.br/authorization?client_id=…"

I think that one solution could be that the initialize method in meli.rb could take an extra param for this purpose. With that, the auth_url inside the config.yml would just act as the default value.

r1goo commented 7 years ago

hi there! I've been experiencing the same issue, just what i did was to overload in the class with my auth_url or creating my self a valid url. Did you solved it already?

lubc commented 7 years ago

hi @r1goo ! yes, I did a PR to this gem with the solution but they never did the review, so it's not merged yet. You can check it out here: https://github.com/mercadolibre/ruby-sdk/pull/11

r1goo commented 7 years ago

thanks 4 your reply @lubc! I've just modify every file as your PR, but im still getting redirected to BR. I also restared the server and hardcoded this in meli.rb . def auth_url(redirect_URI, iso_country_code = "UY") and here

`def self.auth_url_country(iso_country_code)

const_get "AUTHURL#{iso_country_code}"

const_get "https://auth.mercadolibre.com.uy/authorization"

end`

Should i install any gem?

thanks in advance 4 your help bro!