Know how cloud developer api uses python for oauth2 authentication

I hope to know the cloud"s open api, with python requests operation, but always fail, asking the big god to solve the problem.

this is their js example:

https://doc.minapp.com/open-a.

  var request = require("request");

  //  code
  var opt = {
    uri: "https://cloud.minapp.com/api/oauth2/hydrogen/openapi/authorize/",
    method: "POST",
    json: {
      client_id: "a4d2d62965ddb57fa4xx",
      client_secret: "e5802b40135baab9b4e84e35bed058a264c37dxx"
    },
    jar: true,                //  cookie 
    followAllRedirects: true,     // 
  }

  request(opt, function(err, res, body) {
      getToken(body.code)  //  getToken 
  })

  //  token
  function getToken(code) {
    var opt = {
      uri: "https://cloud.minapp.com/api/oauth2/access_token/",
      method: "POST",
      formData: {   //  data  "Content-Type": "multipart/form-data" 
        client_id: "a4d2d62965ddb57fa4xx",
        client_secret: "e5802b40135baab9b4e84e35bed058a264c37dxx",
        grant_type: "authorization_code",
        code,
      }
    }

    request(opt, function(err, res, body) {
      let token = JSON.parse(body).access_token
    })
  }

this is my python code:

import requests
import json

client_id = ""
client_secret = ""
r = requests.post("https://cloud.minapp.com/api/oauth2/hydrogen/openapi/authorize/", json={"client_id": client_id, "client_secret": client_secret})
code = json.loads(r.content)["code"]
print code
-sharpcode

headers = {"Content-Type": "multipart/form-data"}
payload = {"client_id":client_id,"client_secret":client_secret, "grant_type" : "authorization_code", "code" : code}
r = requests.post("https://cloud.minapp.com/api/oauth2/access_token/", headers=headers, data=payload)
print r.content

I don"t know why 400 is always returned

Mar.21,2021

400 is a client error, bad request, estimate related to cookie.


Hello, have you solved this problem? Recently, I also want to find out that Xiaoyun, this open api, got stuck at the first step. Find the method

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32be8-2b386.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32be8-2b386.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?