XeroAPI / xoauth

A CLI tool for obtaining JWTs from OpenId Connect providers
MIT License
49 stars 16 forks source link

xoauth does not output to environment variables on MS Windows #13

Open DavidHChamp opened 4 years ago

DavidHChamp commented 4 years ago

I have implemented xoauth on Windows 10.

It is working except that the '--env' / '-e' switches do not export to environment variables. I have also tried creating the variables in advance on a user account and as system variables but it still does not enter data to them.

Please can this be fixed as the work-around I have via exporting to a file is not robust enough.

JoshBarr commented 4 years ago

As windows lacks an eval() equivalent, I don't think there's an easy way to do this. Even on unix systems you need to eval the output, as a process can only set env_vars for itself and any child processes.

We could add a feature have xoauth generate the temp file, e.g by performing xoauth token -o ./my-env.bat or similar?

DavidHChamp commented 4 years ago

Hi Josh

Thanks for the response.

I am a little confused by your email though, I had expected it to work as it was in your specification (READE.ME file).

On Windows you can set environment variables for user or system level using setx, e.g. "setx variable value" or "setx /m variable value" Also I don't understand why you suggest generating a .bat file, would this be to run a command or to contain the tokens?

I can already use xoauth to export to a file using "xoauth token xero -e > C:\temp\token.txt", I then read it in and parse the contents into my application.

If you can't setup the environment variables directly (which is a shame as I could read these from my application code) what would be more useful for me is for the refresh command to refresh and export using one command e.g. "xoauth token xero -re C:\temp\token.txt"

Regards David davidchamp@icloud.com

On 2 Sep 2020, at 01:34, Josh Barr notifications@github.com wrote:

As windows lacks an eval() equivalent, I don't think there's an easy way to do this. Even on unix systems you need to eval the output, as a process can only set env_vars for itself and any child processes.

We could add a feature have xoauth generate the temp file, e.g by performing xoauth token -o ./my-env.bat or similar?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/XeroAPI/xoauth/issues/13#issuecomment-685207139, or unsubscribe https://github.com/notifications/unsubscribe-auth/APA5VYNQSVD2QJMEE3EHCALSDWHI3ANCNFSM4OEOUAOQ.