CMPE272 : Mastodon API Exercise
git clone https://github.com/kunal768/mastodon-api.gitThe Go server file is located at cmd/master/main.go. To run the server:
- Ensure you have Go installed on your system.
- Navigate to the
cmd/masterdirectory. - Set up your mastodon social account and in developer settings create a project.
- Give read, write and push permissions to the project
- Create a .env in
cmd/masterfile with the following Mastodon account values:
MASTODON_SERVER=your_server_url
CLIENT_KEY=your_client_key
CLIENT_SECRET=your_client_secret
ACCESS_TOKEN=your_access_token
USER_ID=your_user_id
ALLOWED_ORIGIN=your_client_url_with_port- To get value for
USER_IDuse below curl with your Mastodon Social Acccount name and copy theidvalue fromJSONresponse
curl --location 'https://mastodon.social/api/v1/accounts/lookup?acct=<accountname>'- Once the .env file is set up in the
./cmd/masterrun the below command opening shell in the same directory :
go run main.goImportant
to avoid CORS error update ALLOWED_ORIGIN variable in server .env with IP from where below client will be hosted
To set up and run the Next.js client:
- Open another shell and run below command :
npm install && npm run devCongratulations you're good to go ! Made with ❤️