The Apple TV does not have web view, and therefore does not allow you to do oauth on the device.
Logme Link is a simple server (written in python3) that allows you to give your user a link that they can enter in their phone/tablet/computer. They can then log in via this device (and it will then be available on the computer).
In order for the server to run you need to have a redis instance running. You can then just call your server with:
python3 server.py
That's it, your server will then listen on the port 8080 of your localhost.
Note that this repository also contains a Dockerfile and a docker-compose configuration for easy docker deployment.
We need to introduce 2 concept:
- The secret corresponds to the value that is kept between the client and the server. This is what allows the Apple TV client to request the auth information
- The key corresponds to the code give to the user so that she can log into the system
The body posted should be json encoded and has the following values:
service
: the service to connect to (now supports only 'pocket')key
(optional): a pre generated key that will be transmitted to the userfinal_redirect_url
(optional): a url to redirect the client once her authorization has been confirmed
For different service additional information must (or can) be provided
- Pocket
token
: the request token from the API
The call will return a json object with the following values:
secret
: the shared secret for the client app to request the auth infourl
: the redirection url to offer the clientkey
: the client key that will be exposed to the client
Returns the information related to the secret. Can take the query parameter
wait=registered
or wait=redirected
to wait for more information to be
returned (with a timeout of 30 seconds).
returns a json document with the values:
service
: the service related to this secretredirected
: a boolean indicating if a user has been redirected to the serviceregistered
: a boolean indicating if the user is now registered
Additionally the different service expose the variables that are passed to them at creation as well.
A simple sanity check (can be used to make sure the service is up with a tool like pingdom).
Redirects the user to the service related to the key
. When this endpoint is
called changed the redirected
status to True
.
The endpoint where the 3rd party should redirect to. If a final_redirect_url
.
When this endpoint is called changed the registered
status to True
.
The server configuration is done via environment variables:
-
MY_URL
(defaults tohttp://localhost:8080
): the base url that should be returned of the server (use for redirects and link generation). -
KEY_TTL
(defaults to 300): the number of seconds that keys will live - in other word the time you give your users to log in. -
HOST
(defaults to0.0.0.0
): where to listen for calls -
PORT
(defaults to8080
): port to listen to -
REDIS_HOST
(defaults tolocalhost
): where to find the redis instance -
REDIS_PORT
(defaults to6379
): on which port you find the redis instance
To create a new service you can simply create a package exposing the following (async) methods:
async def parse_creation(request_body, request_qs=None)
: receives the data from the_create
call and returns the information that needs to be saved to request more info.async def redirect_url(info, redirect_uri)
: takes the info saved by theparse_creation
function, as well as the uri to be redirected to (which will typically be the/register/:key
url and outputs the link to be redirected to.
You can register it by adding it to the SERVICES dict. Pull requests welcome!
The LogMe Link logo icon has been created by Yaroslav Samoilov from the Noun Project.