Skip to content

Commit

Permalink
remove secret
Browse files Browse the repository at this point in the history
  • Loading branch information
amay077 committed May 6, 2024
1 parent f19f069 commit 5ced1f2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
14 changes: 5 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
const config_dev = {
CLIENT_ID: 'JXKR3OYSVKYPR4YSIYFUXUASGG2SXDIR1I2XDLIWIAMUK2ES',
REDIRECT_URI: 'http://localhost:8080/#/auth',
API_ENDPOINT: `http://localhost:63406/.netlify/functions`,
API_ENDPOINT: `http://localhost:9999/.netlify/functions`,

post_targets: {
mastodon: {
mastodon_cloud: {
name: 'Mastodon.cloud(dev)',
server: 'mastodon.cloud',
MASTODON_CLIENT_ID: 'flr82v9ah3bNegi3f6CUEvG7Vrz02HtIJzqswztaFnQ',
MASTODON_CLIENT_SECRET: 'rpWnOOmhOnd4oHscuEvd55NhuG1gqc4S_7uXsFHsJr0',
client_id: '8G4fffNV00gj5iWLxO7dB91JVnoAY6puZ--9d0atrc4',
},
mstdn_jp: {
name: 'mstdn.jp(dev)',
server: 'mstdn.jp',
MASTODON_CLIENT_ID: 'gIAagB7-8KP6XEW1xHW3Wh3UjOH9A-ircwMlZX-80xw',
MASTODON_CLIENT_SECRET: 'FlJm2oIaLBEJi4uWGk51ke_VPiwYB5lM5vCB5J5Cf9E',
client_id: 'gIAagB7-8KP6XEW1xHW3Wh3UjOH9A-ircwMlZX-80xw',
},
},
twitter: {
Expand All @@ -36,14 +34,12 @@ const config_prod = {
mastodon_cloud: {
name: 'Mastodon.cloud',
server: 'mastodon.cloud',
MASTODON_CLIENT_ID: '8G4fffNV00gj5iWLxO7dB91JVnoAY6puZ--9d0atrc4',
MASTODON_CLIENT_SECRET: 'xW_xpjTdNurUBS-aGMrkx-zsxUeuboaOhs4VufE1LEc',
client_id: '8G4fffNV00gj5iWLxO7dB91JVnoAY6puZ--9d0atrc4',
},
mstdn_jp: {
name: 'mstdn.jp',
server: 'mstdn.jp',
MASTODON_CLIENT_ID: 'gIAagB7-8KP6XEW1xHW3Wh3UjOH9A-ircwMlZX-80xw',
MASTODON_CLIENT_SECRET: 'FlJm2oIaLBEJi4uWGk51ke_VPiwYB5lM5vCB5J5Cf9E',
client_id: 'gIAagB7-8KP6XEW1xHW3Wh3UjOH9A-ircwMlZX-80xw',
}
},
twitter: {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/MainContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,5 @@


<div class="footer">
<button class="disconnect_button" on:click="{disconnect}">Disconnect</button>
<button class="btn btn-outline-primary btn-sm mb-2" on:click="{disconnect}">Disconnect</button>
</div>
14 changes: 4 additions & 10 deletions src/lib/MastodonConnection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
console.error(`onApplyMastodonAccessToken -> settings:`, settings);
return;
}
const url = `https://${settings.server}/oauth/authorize?client_id=${settings.MASTODON_CLIENT_ID}&response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=write`;
const url = `https://${settings.server}/oauth/authorize?client_id=${settings.client_id}&response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=write`;
// url を別タブで開く
window.open(url, '_blank');
Expand All @@ -34,16 +34,10 @@
return;
}
const res = await fetch(`https://${settings.server}/oauth/token`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `client_id=${settings.MASTODON_CLIENT_ID}&client_secret=${settings.MASTODON_CLIENT_SECRET}&grant_type=authorization_code&code=${mastodonCode}&redirect_uri=urn:ietf:wg:oauth:2.0:oob`,
});
const res = await fetch(`${Config.API_ENDPOINT}/mastodon_token?server=${settings.server}&code=${mastodonCode}`);
if (!res.ok) {
console.error(`FIXME h_oku 後で消す -> onApplyMastodonAccessToken -> res:`, res);
console.error(`failed to fetch:`, res);
return;
}
Expand All @@ -52,7 +46,7 @@
savePostSetting(postSettings);
dispatch('onChange');
alert('Mastodon に接続しました。toot ボタンで投稿できます。');
alert('Mastodon に接続しました。');
};
</script>

Expand Down
3 changes: 0 additions & 3 deletions src/lib/TwitterConnection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
const onConnectToTwitter = () => {
// const url = `https://twitter.com/i/oauth2/authorize?response_type=code&client_id=cFdITnRJb2t6Z1FYTktjUmU0WFg6MTpjaQ&redirect_uri=http%3A%2F%2Flocalhost%3A8080&scope=tweet.read%20tweet.write%20users.read%20offline.access&state=twitter_callback&code_challenge=challenge&code_challenge_method=plain`;
const url = `https://twitter.com/i/oauth2/authorize?response_type=code&client_id=${Config.post_targets.twitter.client_id}&redirect_uri=${Config.post_targets.twitter.redirect_uri}&scope=tweet.read%20tweet.write%20users.read&state=twitter_callback&code_challenge=challenge&code_challenge_method=plain`;
// const url = `https://${settings.server}/oauth/authorize?client_id=${settings.MASTODON_CLIENT_ID}&response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=write`;
// url をこのタブで開く
window.open(url, '_self');
Expand Down

0 comments on commit 5ced1f2

Please sign in to comment.