Skip to content

Instantly share code, notes, and snippets.

@matthewjackowski
Last active December 8, 2015 13:39
Show Gist options
  • Select an option

  • Save matthewjackowski/87f9c65f2332e2bab504 to your computer and use it in GitHub Desktop.

Select an option

Save matthewjackowski/87f9c65f2332e2bab504 to your computer and use it in GitHub Desktop.
def handleAuthError
puts 'Put error handling code here'
end
project_params = {
slug: "test-#{SecureRandom.uuid}",
description: 'wpml_project',
organization: user_data[:org_slug],
:private => true,
source_language_code: 'en',
name: "Test project-#{SecureRandom.uuid}"
}
begin
project = Transifex::Projects.create(project_params)
project.fetch
rescue => e
handleAuthError if e.message.include? 'Authorization Required'
end
@matthewjackowski
Copy link
Author

Yes, I agree the intent is to use a single set of credentials at a time. Using security credentials between multiple systems is very problematic with just username and password and can often result in these values being stored remotely without the users knowledge. A better solution is to us a Auth protocol like OAuth which works off of tokens that a user can revoke.

Although, I'm not sure I understand why you need to authenticate as multiple different users. It's really difficult for me to understand what you are trying to accomplish without seeing the code that you are referencing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment