Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
Switch to access keys/tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
derkweijers committed Apr 20, 2023
1 parent 6342732 commit 45c53d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ AMQP_URL=
DEBUG=
DB_LOCATION=
SENTRY_DSN=
TWITTER_BEARER_TOKEN=
API_KEY=
API_SECRET=
ACCESS_TOKEN=
ACCESS_TOKEN_SECRET=
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snapi-twitter-bot",
"version": "1.4.0",
"version": "1.4.1",
"description": "The official Twitter bot for the Spaceflight News API.",
"main": "app.js",
"scripts": {
Expand Down
7 changes: 6 additions & 1 deletion src/utils/TwitterClientV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import {TweetV2PostTweetResult, TwitterApi} from 'twitter-api-v2';
import {Tweet} from "../entity/Tweet";

class TwitterClientV2 {
private client = new TwitterApi(process.env.TWITTER_BEARER_TOKEN ?? "").v2;
private client = new TwitterApi({
appKey: process.env.API_KEY!,
appSecret: process.env.API_SECRET!,
accessToken: process.env.ACCESS_TOKEN!,
accessSecret: process.env.ACCESS_TOKEN_SECRET!,
}).v2;

async sendTweet(tweet: Tweet): Promise<TweetV2PostTweetResult | void> {
const tweetText = `New ${tweet.type} from ${tweet.newsSite.name}: ${tweet.title} - ${tweet.url} #space #spaceflight #news`;
Expand Down

0 comments on commit 45c53d2

Please sign in to comment.