imLinguin / nile

Unofficial Amazon Games client
GNU General Public License v3.0
306 stars 16 forks source link

feat: implemented non-interactive login flow #28

Closed Gustash closed 1 year ago

Gustash commented 1 year ago

Closes #27

Non-interactive Login Support

This PR adds the ability to login without having to go through the interactive login flow (aka currently the only way to login)

Changes

Example flow

A user calls nile auth --login --non-interactive. Example output:

{
  "client_id": "4538354532414338313846393131454541343733443843423841353038303341234132554d56484f58375550345637",
  "code_verifier": "ZiT3nDc3NNeEQysbk4O65E1b7FG3-UhL-DqopBcir4g",
  "serial": "E85E2AC818F911EEA473D8CB8A50803A",
  "url": "https://amazon.com/ap/signin?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.oa2.scope=device_auth_access&openid.ns.oa2=http%3A%2F%2Fwww.amazon.com%2Fap%2Fext%2Foauth%2F2&openid.oa2.response_type=code&openid.oa2.code_challenge_method=S256&openid.oa2.client_id=device%3A4538354532414338313846393131454541343733443843423841353038303341234132554d56484f58375550345637&language=en_US&marketPlaceId=ATVPDKIKX0DER&openid.return_to=https%3A%2F%2Fwww.amazon.com&openid.pape.max_auth_age=0&openid.assoc_handle=amzn_sonic_games_launcher&pageId=amzn_sonic_games_launcher&openid.oa2.code_challenge=L2hAj3KpxhxvHjdn4_zVuDdB8cS9zz6pjX7JMbHMjHs"
}

The user then follows the url and completes the web login.

After that, they take the authorization code from the openid.oa2.authorization_code query parameter in the redirect URL.

Finally, the user calls nile register --code AUTHORIZATION_CODE --client-id CLIENT_ID --code-verifier CODE_VERIFIER --serial SERIAL.

After this, the user is logged in.