Module: FellowshipOneAPI::OAuth::CredentialsAuthentication
- Includes:
- FellowshipOneAPI::OAuth
- Defined in:
- lib/f1api/oauth/credentials_authentication.rb
Overview
Implements the Credentials method of authentication. You must manage the credentials.
Instance Attribute Summary
Attributes included from FellowshipOneAPI::OAuth
#authenticated_user_uri, #oauth_access_token, #oauth_consumer, #oauth_consumer_key, #oauth_consumer_secret
Instance Method Summary collapse
-
#authenticate!(username, password, type = :portal) ⇒ Object
(also: #authorize!)
- Authorizes a user
username - The username of the user
password - The password of the user
type -
Can be :portal or :weblink based on which credentials you want to authenticate against Returns the URI for the authenticated user.
- The password of the user
- The username of the user
- Authorizes a user
Methods included from FellowshipOneAPI::OAuth
Instance Method Details
#authenticate!(username, password, type = :portal) ⇒ Object Also known as:
Authorizes a user
username-
The username of the user
password-
The password of the user
type-
Can be :portal or :weblink based on which credentials you want to authenticate against
Returns the URI for the authenticated user
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/f1api/oauth/credentials_authentication.rb', line 11 def authenticate!(username, password, type = :portal) load_consumer_config(type) if @oauth_consumer.nil? cred = URI.encode(Base64.encode64("#{username} #{password}")) case type when :portal auth_url = FellowshipOneAPI::Configuration.portal_credential_token_path when :weblink auth_url = FellowshipOneAPI::Configuration.weblink_credential_token_path end response = @oauth_consumer.request(:post, auth_url, nil, {}, "ec=#{cred}", {'Content-Type' => 'application/x-www-form-urlencoded'}) handle_response_code(response) # Gettting the URI of the authenticated user @authenticated_user_uri = response["Content-Location"] end |