'Why is python with Tipeeestream api not working?

im am trying to login in my Tipeeestream Account using the Tipeeestream Api key. But its not working(i got message:forbidden). Here is my code:

import sys
import requests

if len(sys.argv) != 5:
    print("Usage: python " + sys.argv[0] + " <apiKey> <provider> <access_token> <refresh_token>")
    exit()

apikey = sys.argv[1]
provider = sys.argv[2]
access_token = sys.argv[3]
refresh_token = sys.argv[4]

print("Getting username")

try:
    r = requests.get('https://api.tipeeestream.com/v1.0/me?apiKey=' + apikey)

    if "username" in r.json():
        username = r.json()["username"]

        print("Username " + username)

        data = {
            "access_token": access_token,
            "origin": "managementSecurity",
            "provider": provider,
            "refresh_token": refresh_token
        }

        try:
            r = requests.post('https://www.tipeeestream.com/v1.0/users/' + username + '/providers?apiKey=' + apikey, json=data)
            print(r)
            if "code" in r.json():
                if r.json()["code"] == 200:
                    print("Log in to " + username)
                else:
                    print("Error by loging in " + username)
            else:
                print("Error by loging in " + username)
        except:
            print("Error by loging in " + username)
except:
    print("Error by getting username")

I have no idea how to fix it. I hope you can help me...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source