{"metadata":{"image":[],"title":"","description":""},"api":{"url":"/v2/sessions/auth/key","auth":"required","method":"post","examples":{"codes":[{"code":"'''\nThis is a Python 3.7 Module that Submits an Auth Token\nand returns an API key for authentication\n'''\nimport json\nimport secrets\nimport requests\nimport urllib.parse\n\n\nclass WyreApi:\n\n    API_URL = \"https://api.testwyre.com\"\n    API_VER2 = \"/v2\"\n    API_SESSIONS_PATH = \"/sessions/auth/key\"\n\n    def generate_token(self, tok_length=30):\n        '''\n            This method generates a secret token using secrets\n            in Python3\n        '''\n        return secrets.token_hex(tok_length)\n\n    def submitAuthToken(self, token):\n        '''\n            This method submits the secret key / token generated above\n            and to https://api.sendwyre.com/v2/sessions/auth/key\n            and sets API_KEY to the API key returned\n        '''\n        if not token:\n            print(\"Please generate a 25-35 length token\")\n            return\n\n        params = {\n            \"secretKey\": token\n        }\n        url = WyreApi.API_URL + WyreApi.API_VER2 + WyreApi.API_SESSIONS_PATH + \"?\" + \\\n            urllib.parse.urlencode(params, encoding='utf-8')\n\n        response = requests.post(url)\n        if response.status_code == 200:\n            return json.loads(response.text)\n        else:\n            print(response.text)\n\n\nif __name__ == \"__main__\":\n    # create a wyre class object\n    wyre = WyreApi()\n\n    # generate a wyre token\n    token = wyre.generate_token()\n    print(\"Token\", token)\n    # get a secret key\n    response = wyre.submitAuthToken(token)\n    if response:\n        print(\"API KEYS\", response.get('apiKey'))","language":"python"},{"code":"################### Generate a secrey key ###################\n# On a Linux Environment\ndate +%s | sha256sum | base64 | head -c 32 ; echo\n\n# This will generate a random secret key. Do not lose this key. Once this key is generated, it will be tied to your API Key associated with your account. Here are other ways to generate a secret key in a Linux environmnet. https://www.howtogeek.com/howto/30184/10-ways-to-generate-a-random-password-from-the-command-line/\n\ncurl -XPOST \\\n-H \"Content-Type: application/json\" \\\n-d '{\"secretKey\": \"ENTER YOUR SECRET KEY HERE\"}' \\\nhttps://api.testwyre.com/v2/sessions/auth/key\n\n# This will return a JSON object with your API key. Use our test environment first before going into production.\n\n\n","language":"curl"}]},"results":{"codes":[{"status":200,"language":"json","code":"{\n  \"apiKey\": \"AK-XXXX-YYYYY-ZZZZZ-QQQQQ\",\n  \"authenticatedAs\": null\n}","name":""}]},"settings":"","params":[{"name":"secretKey","type":"string","default":"","desc":"A 25-35 character randomly generated string to use as the key. Any valid JSON string without newlines is acceptable","required":false,"in":"body","ref":"","_id":"5c1d77ffeace490020c1b9d2"}],"apiSetting":"5c50b085aae6150014b3e80e"},"next":{"description":"","pages":[]},"title":"Submit Auth Token","type":"endpoint","slug":"initialize-auth-token","excerpt":"Process a client-generated secret key to use as an auth token","body":"Use this method as describe in [Authentication](doc:authentication#token-auth) to initialize a client-generated bearer token.","updates":["5cf4f15f00e667005d6e9f05"],"order":1,"isReference":true,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5c1d77ffeace490020c1b9d1","project":"550f74bb6fc8130d0038aad3","version":{"version":"3","version_clean":"3.0.0","codename":"","is_stable":true,"is_beta":true,"is_hidden":false,"is_deprecated":false,"categories":["550f75de61d9d30d00af9e02","551027e38579861900a86698","551029e08579861900a8669a","551029e7498062190006328a","5bc633a722d682005c9ad9e4","5bc633b08c4b0b000d6a7eaa","5bc633b48f3ff600626e3e18","5bc63538e5a6ba000d22ee6d","5bc63587a18a6b000decd295","5bc635c0937fcb0056223d9c","5bc6360f42f41800319aeaa6","5be5d13ff1d319002baca9ce","5be5d2287cd14d00291fbfdb","5be8b3b09f7cb70023c56a39","5be8b3cbb910100044e20206","5c1d769a4f6aed001fe527f0","5c402942010f0d001496dded","5e8127d61c906800374eeb1c"],"_id":"550f75de61d9d30d00af9e01","__v":18,"releaseDate":"2015-03-23T02:09:34.221Z","project":"550f74bb6fc8130d0038aad3","createdAt":"2015-03-23T02:09:34.221Z","forked_from":"550f74bb6fc8130d0038aad6"},"category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Key Management","slug":"auth","order":5,"from_sync":false,"reference":true,"_id":"5c1d769a4f6aed001fe527f0","project":"550f74bb6fc8130d0038aad3","version":"550f75de61d9d30d00af9e01","createdAt":"2018-12-21T23:26:18.126Z","__v":0},"user":"56ddd4424acab82000ae9d30","createdAt":"2018-12-21T23:32:15.478Z","__v":10,"parentDoc":null}

postSubmit Auth Token

Process a client-generated secret key to use as an auth token

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

secretKey:
string
A 25-35 character randomly generated string to use as the key. Any valid JSON string without newlines is acceptable

Examples


Result Format


Documentation

Use this method as describe in [Authentication](doc:authentication#token-auth) to initialize a client-generated bearer token.