CMPE272 : Mastodon API Exercise
git clone https://github.com/kunal768/mastodon-api.git
The 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/master
directory. - 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/master
file 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_ID
use below curl with your Mastodon Social Acccount name and copy theid
value fromJSON
response
curl --location 'https://mastodon.social/api/v1/accounts/lookup?acct=<accountname>'
- Once the .env file is set up in the
./cmd/master
run the below command opening shell in the same directory :
go run main.go
Important
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 dev
Congratulations you're good to go ! Made with ❤️