@rem https://stackoverflow.com/questions/53357741/how-to-perform-oauth-2-0-using-the-curl-cli
@rem https://www.jhanley.com/google-oauth-2-0-testing-with-curl/

set CLIENT_ID=fa4b103cc97928453a346427fb380023e996dd8299190663
set CLIENT_SECRET=9bd2428add6f480a1bd626a2a376d354ef20b580ef340023e996dd8299190663
set SCOPE=
set ENDPOINT=https://logincert.anaf.ro/anaf-oauth2/v1/authorize

@rem set URL="%ENDPOINT%?client_id=%CLIENT_ID%&client_secret=%CLIENT_SECRET%&response_type=code&scope=%SCOPE%&access_type=offline&redirect_uri=https://oauth.pstmn.io/v1/callback"
set URL="%ENDPOINT%?client_id=%CLIENT_ID%&client_secret=%CLIENT_SECRET%&response_type=code&redirect_uri=https://oauth.pstmn.io/v1/callback"

@REM start iexplore %URL%
@REM start microsoft-edge:%URL%
start chrome %URL%

set /p AUTH_CODE="Enter Code displayed in browser: "

curl ^
--data client_id=%CLIENT_ID% ^
--data client_secret=%CLIENT_SECRET% ^
--data code=%AUTH_CODE% ^
--data redirect_uri=https://oauth.pstmn.io/v1/callback ^
--data grant_type=authorization_code ^
https://logincert.anaf.ro/anaf-oauth2/v1/token