Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

SC.connect doesn't make sure that oauth_token is valid

オープン
#32 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript

調査の方向性

Start by tracing SC.connect, SC.isConnected, and config.set, focusing on how an existing oauth_token is handled and how the /me request reports a 401. Confirm that an invalid token can be cleared or rejected without reloading the page, then verify the reconnect flow and existing authentication behavior.

索引モデルが issue の本文から書いたものです。

説明

With the previous SDK version, I could avoid a login popup every pageload by doing this:

var params = {
    client_id:    '...',
    redirect_uri: '...',
    scope:        'non-expiring'
};
var auth = localStorage.getItem('auth-token');
if (auth) {
    params.access_token = auth;
}
SC.initialize(params);

// ...

function connectionCallback() {
    localStorage.setItem('auth-token', SC.accessToken());
    onConnected();
    SC.get('/me', gotUserdata);
}

if (SC.isConnected()) {
    // make sure we really are
    SC.get('/me', function(user, err) {
        if (!!err) {
            // Error exists, connectify
            SC.connect(connectionCallback);
        } else {
            // We're in
            onConnected();
            gotUserdata(user);
        }
    });
} else {
    SC.connect(connectionCallback);
}

However now isConnected is simply

  isConnected () {
    return config.get('oauth_token') !== undefined;
  },

and connect does this:

  // resolve immediately when oauth_token is set
  const oauth_token = config.get('oauth_token');
  if (oauth_token) {
    return new Promise((resolve) => { resolve({oauth_token}); });
  }

I thought I could get around this by checking for a 401 when fetching /me, but unfortunately I can't null out the oauth_token config value:

  set(key, value) {
    if (value) {
      config[key] = value;
    }
  }

The best I can think of now is to delete the localStorage value and reload the page, but that's not very nice.

主要言語
JavaScript
スター
388
フォーク
76
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

soundcloud/soundcloud-javascript のほかの issue

soundcloud/soundcloud-javascript の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。