Alexa-remote2でProxy認証が通らないときのカスタマイズ(alexa-cookie2@3.4.3)

  • 投稿日:
  • by

alexa-cookie.jsの変更

$cd ~/.node-red/node_modules/alexa-cookie2/
$cp alexa-cookie.js alexa-cookie.js.org
$vi alexa-cookie.js

「_options = __options;」の記載を探し、この下の行に「_options.baseAmazonPage='amazon.co.jp';」の行を追加します。

_options = __options;
_options.baseAmazonPage='amazon.co.jp'; //<--この行を追加

proxy.jsの変更

$cd lib
$cp proxy.js proxy.js.org
$vi proxy.js

181行目付近「returnedInitUrl =」以降を書き換え

// returnedInitUrl = `https://www.${_options.baseAmazonPage}/ap/signin?openid.return_to=https%3A%2F%2Fwww.${_options.baseAmazonPage}%2Fap%2Fmaplanding&openid.assoc_handle=amzn_dp_project_dee_ios${_options.baseAmazonPageHandle}&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&pageId=amzn_dp_project_dee_ios${_options.baseAmazonPageHandle}&accountStatusPolicy=P1&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns.oa2=http%3A%2F%2Fwww.${_options.baseAmazonPage}%2Fap%2Fext%2Foauth%2F2&openid.oa2.client_id=device%3A${deviceId}&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.oa2.response_type=token&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.pape.max_auth_age=0&openid.oa2.scope=device_auth_access&language=${_options.amazonPageProxyLanguage}`;
returnedInitUrl =`https://www.amazon.co.jp/ap/signin?showRmrMe=1&openid.return_to=https%3A%2F%2Falexa.amazon.co.jp%2F&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=amzn_dp_project_dee_jp&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&`;

「/spa/index.html」は既に追加されているので、変更は以上。
Node-redを再起動します。

Alexa-remote2でAlexaにログインできない場合の対処法(Alexa-Cookie v3.2.1版)を参考にさせていただきました。