OAuth2 connections

I was able to get it to work, but it’s unclear to me whether I used OAuth, or another feature that’s unique to this vendor. I followed some sample code from them using Curl and translated it to Jython. Below is the code in my script that contacts the server to retrieve the data. Not sure if this works for any site other than the one I’m working with.

username = ‘username’
password = ‘password’
ClientID = ‘xxx’
ClientSecret = ‘xxx’
AccessToken = system.tag.read(“AccessToken”).value
headers = {“Content-Type”:“application/json”, “Authorization”:"Bearer "+AccessToken}
MeterBase = “https://site/
Modifiers = “/data?format=json&resolution=”

try:
response = system.net.httpGet(MeterBase+MeterID+Modifiers, headerValues = headers)
except:
response = system.net.httpPost(“https://site.com/o/token/”, {“client_id”:ClientID, “client_secret”:ClientSecret, “username”:username, “password”:password, “grant_type”:“password”})
PyResponse = system.util.jsonDecode(response)

AccessToken = PyResponse["access_token"]
RefreshToken = PyResponse["refresh_token"]

system.tag.write("AccessToken", AccessToken)
system.tag.write("RefreshToken", RefreshToken)
headers = {"Content-Type":"application/json", "Authorization":"Bearer "+AccessToken}
response = system.net.httpGet(MeterBase+MeterID+Modifiers, headerValues = headers)