get-oauth-token
is a command line tool to obtain a fresh OAuth2 access
token using a refresh token. It's designed to work with any OAuth2
provider and outputs tokens in a format suitable for direct use in other
tools.
While this tool was originally created to support mailsend-go's XOAUTH2 authentication, it can be used with any application that needs OAuth2 token refresh capabilities.
The reason for using a refresh token is that access tokens are intentionally short-lived for security reasons (usually 1 hour), so a refresh token lets you get a new access token without user intervention when the short-lived one expires.
go install github.com/muquit/get-oauth-token@latest
Please look at Makefile for compiling for various platforms
make
or
go build
TODO
Basic usage with Google OAuth2 (default provider):
get-oauth-token -r "refresh_token" -i "client_id" -s "client_secret"
Use with mailsend-go:
mailsend-go -auth XOAUTH2 -user email@gmail.com -pass $(get-oauth-token -r "token" -i "id" -s "secret")
-r, -refresh-token Refresh token (required)
-i, -client-id Client ID (required)
-s, -client-secret Client secret (required)
-e, -endpoint Token endpoint URL
-p, -provider Provider (google, microsoft, yahoo)
-j, -json Output full JSON response
-v, -verbose Show detailed progress and error messages
- Google (default)
- Microsoft
- Yahoo
- Custom endpoints via -e flag
Microsoft OAuth2:
get-oauth-token -p microsoft -r "refresh_token" -i "client_id" -s "client_secret"
Custom OAuth2 server:
get-oauth-token -e "https://custom.oauth.server/token" -r "refresh_token" -i "client_id" -s "client_secret"
Get full token information:
get-oauth-token -r "refresh_token" -i "client_id" -s "client_secret" -j
If you have any questions, requests or suggestions, please enter them in Issues with appropriate labels.
Claude AI 3.5 Sonnet with instructions from muquit@muquit.com