Skip to content

Commit

Permalink
Fix basic auth (#72)
Browse files Browse the repository at this point in the history
* fix basic auth

* version 0.9.8

* add github sample
  • Loading branch information
mamantoha authored Mar 18, 2018
1 parent 354ad2e commit f87ab28
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions samples/github.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require "../crest"

user = ENV["GITHUB_USER"]
key = ENV["GITHUB_KEY"]

client = Crest::Resource.new(
"https://api.github.com",
user: user,
password: key,
logging: true,
)

response = client["/search/repositories?q=language=Crystal"].get
puts response.body
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: crest
version: 0.9.7
version: 0.9.8

authors:
- Anton Maminov <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/crest/request.cr
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ module Crest
private def basic_auth(user, password)
return unless user && password

value = "Basic " + Base64.encode(user + ":" + password).chomp
value = "Basic #{Base64.strict_encode("#{user}:#{password}")}"
@headers.add("Authorization", value)
end

Expand Down
2 changes: 1 addition & 1 deletion src/crest/version.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Crest
VERSION = "0.9.7"
VERSION = "0.9.8"
end

0 comments on commit f87ab28

Please sign in to comment.