{"action":"created","issue":{"url":"https://api.github.com/repos/twilio/twilio-ruby/issues/129","labels_url":"https://api.github.com/repos/twilio/twilio-ruby/issues/129/labels{/name}","comments_url":"https://api.github.com/repos/twilio/twilio-ruby/issues/129/comments","events_url":"https://api.github.com/repos/twilio/twilio-ruby/issues/129/events","html_url":"https://github.com/twilio/twilio-ruby/pull/129","id":53303148,"number":129,"title":"Compute auth_token dynamically based on AccoundSid from request params","user":{"login":"karthiks","id":130831,"avatar_url":"https://avatars.githubusercontent.com/u/130831?v=3","gravatar_id":"","url":"https://api.github.com/users/karthiks","html_url":"https://github.com/karthiks","followers_url":"https://api.github.com/users/karthiks/followers","following_url":"https://api.github.com/users/karthiks/following{/other_user}","gists_url":"https://api.github.com/users/karthiks/gists{/gist_id}","starred_url":"https://api.github.com/users/karthiks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karthiks/subscriptions","organizations_url":"https://api.github.com/users/karthiks/orgs","repos_url":"https://api.github.com/users/karthiks/repos","events_url":"https://api.github.com/users/karthiks/events{/privacy}","received_events_url":"https://api.github.com/users/karthiks/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-01-03T12:39:22Z","updated_at":"2015-01-07T17:07:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/twilio/twilio-ruby/pulls/129","html_url":"https://github.com/twilio/twilio-ruby/pull/129","diff_url":"https://github.com/twilio/twilio-ruby/pull/129.diff","patch_url":"https://github.com/twilio/twilio-ruby/pull/129.patch"},"body":"Hi,\r\n\r\nWe are using Twilio with its sub-accounts feature extensively. Our business use-case is such that the Twilio web-hook request comes from the sub-account's TwiML app. Existing Rack while being a sweet convenience, doesn't have the feature to dynamically fetch the Twilio's Auth-Token based on the `AccountSid` of the sub-account. Because this AccountSid is sent with the request params from Twilio, it makes sense to fetch the auth-token for that sub-account from our end.\r\n\r\nThis PR is a tested patch enhancing the Rack to get auth-token dynamically. How can it be done? Simply pass nil instead of the auth_token argument, making the rack to call the `getAuthToken(account_sid)` method. The end-user can over-ride this method to suit their implementation of fetching the `AuthToken` based on `account_sid`\r\n\r\nIn our case for instance, we create `config/initializers/twilio.rb` in our rails project with code something like below:\r\n```\r\nmodule Rack\r\n  class TwilioWebhookAuthentication\r\n    def getAuthToken account_sid\r\n      return '' if account_sid.nil?\r\n      user = User.find_by_twilio_account_sid(account_sid)\r\n      user.present? ? user.tauthtoken : ''\r\n    end\r\n  end\r\nend\r\n\r\n```\r\n\r\nHope you like it and others find it useful :)"},"comment":{"url":"https://api.github.com/repos/twilio/twilio-ruby/issues/comments/69054224","html_url":"https://github.com/twilio/twilio-ruby/pull/129#issuecomment-69054224","issue_url":"https://api.github.com/repos/twilio/twilio-ruby/issues/129","id":69054224,"user":{"login":"skimbrel","id":484269,"avatar_url":"https://avatars.githubusercontent.com/u/484269?v=3","gravatar_id":"","url":"https://api.github.com/users/skimbrel","html_url":"https://github.com/skimbrel","followers_url":"https://api.github.com/users/skimbrel/followers","following_url":"https://api.github.com/users/skimbrel/following{/other_user}","gists_url":"https://api.github.com/users/skimbrel/gists{/gist_id}","starred_url":"https://api.github.com/users/skimbrel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skimbrel/subscriptions","organizations_url":"https://api.github.com/users/skimbrel/orgs","repos_url":"https://api.github.com/users/skimbrel/repos","events_url":"https://api.github.com/users/skimbrel/events{/privacy}","received_events_url":"https://api.github.com/users/skimbrel/received_events","type":"User","site_admin":false},"created_at":"2015-01-07T17:07:40Z","updated_at":"2015-01-07T17:07:40Z","body":"Just need signoff from @philnash — this code is his domain :)"}}