Skip to content
This repository has been archived by the owner on Apr 3, 2021. It is now read-only.

Commit

Permalink
Add support for different locales
Browse files Browse the repository at this point in the history
  • Loading branch information
omarroth committed Jul 10, 2019
1 parent f53ca08 commit a537850
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 68 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ Sessions can be saved using `to_json` and `from_json`, like so:
```crystal
require "audible"
client = Audible::Client.new("EMAIL", "PASSWORD")
client = Audible::Client.new("EMAIL", "PASSWORD", locale: "us")
File.write("session.json", client.to_json)
# Sometime later...
client = Audible::Client.from_json(File.read("session.json"))
```

Logging in currently requires answering a CAPTCHA. By default a user prompt will be provided using `readline`, which looks like:
Expand All @@ -52,10 +51,10 @@ A custom callback can be provided (for example submitting the CAPTCHA to an exte
```crystal
require "audible"
client = Audible::Client.new("EMAIL", "PASSWORD") do |captcha_url|
client = Audible::Client.new("EMAIL", "PASSWORD", locale: "us") do |captcha_url|
# Do some things with the captcha_url ...
return "My answer for CAPTCHA"
"My answer for CAPTCHA"
end
```

Expand All @@ -74,13 +73,23 @@ def custom_otp_callback
return "My OTP code"
end
client = Audible::Client.new("USERNAME", "PASSWORD", otp_callback: ->custom_otp_callback)
client = Audible::Client.new("USERNAME", "PASSWORD", locale: "us", otp_callback: ->custom_otp_callback)
# Or directly as proc:
client = Audible::Client.new("USERNAME", "PASSWORD", otp_callback: ->{ return "My OTP code"})
client = Audible::Client.new("USERNAME", "PASSWORD", locale: "us", otp_callback: ->{ return "My OTP code" })
```

## Locales

This API supports 5 countries natively:

- USA (locale: "us")
- Germany (locale: "de")
- United Kingdom (locale: "uk")
- France (locale: "fr")
- Canada (locale: "ca")

## Authentication

Clients are authenticated using OpenID. Once a client has successfully authenticated with Amazon, they are given an access token and refresh token for authenticating with Audible.
Expand Down
Loading

0 comments on commit a537850

Please sign in to comment.