oda-hub / oda_api

API client to access some of the MMODA resources: INTEGRAL, POLAR, ANTARES, LIGO/Virgo, SDSS
Other
2 stars 1 forks source link

make to request password if indicated, and store in home file #34

Open volodymyrss opened 3 years ago

volodymyrss commented 3 years ago

it's common to run some workflows using oda_api in semi-automated or automated way.

in such cases, token should be provide from somewhere else but the code itself. one could make workflows discover token, but standard token discovery could be directly in oda_api

in the following order:


in addition, the token could be inspected and used informated, as so:

print("\033[31moda token, to access dispatcher\033[0m", 
      json.dumps(json.loads(base64.b64decode(token.split(".")[1]+"=").decode()), indent=4, sort_keys=True))

print("\033[31mcookie token, to access closed instance\033[0m", 
      json.dumps(json.loads(base64.b64decode(cookies['_oauth2_proxy'].split(".")[0]+"=").decode()), indent=4, sort_keys=True))
oda token, to access dispatcher {
    "email": "Volodymyr.Savchenko@unige.ch",
    "exp": 1626374556,
    "name": "sitamin",
    "roles": "authenticated user, administrator, content manager, general, integral-private-qla, magic, unige-hpc-full, public-pool-hpc, antares",
    "sub": "Volodymyr.Savchenko@unige.ch"
}
cookie token, to access closed instance {
    "Email": "vladimir.savchenko@gmail.com",
    "User": "volodymyrss"
}

Note that there are two tokens. oauth token could be disregarded for now, maybe leaving a comment/todo.

volodymyrss commented 3 years ago

what do you think, @burnout87? It is possible though there is no time this week.

Note that I made this integral-project label to indicate issues which are not necessarily urgent for ODA, but especially directly useful for INTEGRAL project.

burnout87 commented 3 years ago

It is definitely interesting and useful.

To consider, that we will have to instruct the users to save their token in the various location (env_var, $HOME directory etc).

But besides that, it is not difficult to implement.

volodymyrss commented 3 years ago

It is definitely interesting and useful.

To consider, that we will have to instruct the users to save their token in the various location (env_var, $HOME directory etc).

This kind of stuff goes in user guide. It's also part of this repository.

It should not change the default behavior.

But besides that, it is not difficult to implement.

ok!