fossasia / susi_server

SUSI.AI server backend - the Artificial Intelligence server for personal assistants https://susi.ai
GNU Lesser General Public License v2.1
2.51k stars 1.08k forks source link

Fix User Level API #1363 #1365

Closed fragm3 closed 5 years ago

fragm3 commented 5 years ago

Fixes #1363

Changes: Fixes user level api

For http://localhost:4000/aaa/getApiKeys.json,

{
  "keys": {"wolframalphaKey": {"value": "test value"}},
  "session": {"identity": {
    "type": "email",
    "name": "shubh1234m1@gmail.com",
    "anonymous": false
  }},
  "accepted": true,
  "message": "Success : Fetched all API key successfully !"
}

For user api, http://localhost:4000/aaa/getApiKeys.json?type=user&access_token=gzTPX50EfAXrpTZtiZrJNao94H00P5, getting:

{
  "keys": {"MAP_KEY": {"value": "test"}},
  "session": {"identity": {
    "type": "email",
    "name": "shubh1234m1@gmail.com",
    "anonymous": false
  }},
  "accepted": true,
  "message": "Success : Fetched all API key successfully !"
}

For storing user level API: http://localhost:4000/aaa/apiKeys.json?keyName=MAP_KEY&keyValue=test123456&type=user&access_token=p7Pmaz7EdJS7oIVHq1u2wKVLA96hC0

{
  "session": {"identity": {
    "type": "email",
    "name": "shubh12345am@gmail.com",
    "anonymous": false
  }},
  "accepted": true,
  "message": "Added new API key MAP_KEY successfully !"
}