Convert to Lolicode

HI everyone,
i need to convert this code into Lolicode.

var client_id = 'CLIENT_ID';
var client_secret = 'CLIENT_SECRET';

var authOptions = {
  url: 'https://example.com',
  headers: {
    'Authorization': 'Basic ' + (new Buffer(client_id + ':' + client_secret).toString('base64'))
  },
  form: {
    grant_type: 'client_credentials'
  },
  json: true
};

request.post(authOptions, function(error, response, body) {
  if (!error && response.statusCode === 200) {
    var token = body.access_token;
  }
});

I’m trying with this but it doesn’t work.

BLOCK:ConstantString
LABEL:CRED
  value =$"<input.USERNAME>:<input.PASSWORD>"
  => VAR @CRED
ENDBLOCK

BLOCK:ByteArrayToBase64String
LABEL:BASE64
  bytes = @CRED
  => VAR @BASE64
ENDBLOCK

BLOCK:HttpRequest
LABEL:LOGIN
  url = "https://example.com"
  method = POST
  customHeaders = ${("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36"), ("Pragma", "no-cache"), ("Accept", "*/*"), ("Accept-Language", "en-US,en;q=0.8"), ("Authorization", "Basic <BASE64>")}
  TYPE:STANDARD
  "{grant_type:'client_credentials'}"
  "application/json"
ENDBLOCK

I think json doesn’t support single quotes so you might want to use
{"grant_type": "client_credentials"}
in your post data. Both the key and the value (since it’s a string) should be double-quoted as far as I remember. You’re using the python/js syntax for dictionaries but it won’t work for plain json.

1 Like