使用WebApi进行Google身份验证 - BadRequest

时间:2016-02-03 06:51:51

标签: c# node.js asp.net-web-api asp.net-web-api2

Node.Js中的代码

DELIMITER ;;
CREATE PROCEDURE insert_group_alert(
  IN _some_data_a         VARCHAR(255),
  IN _data_list_b         TEXT,
)
  BEGIN
    DECLARE strLen    INT DEFAULT 0;
    DECLARE SubStrLen INT DEFAULT 0;
    DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
      ROLLBACK;
    END;
    START TRANSACTION;

    INSERT INTO TableA (
      some_data,
      counter
    )
    VALUES (
      _some_data_a,
      1
    ) -- you do not really need this, since you do not provide an id
    ON DUPLICATE KEY UPDATE
      counter          = counter + 1;

    SELECT last_insert_id()
      INTO @newId;

    do_this:
      LOOP
        SET strLen = CHAR_LENGTH(_data_list_b);

        INSERT INTO TableB (table_a_id, some_data) VALUES(@newId,SUBSTRING_INDEX(_data_list_b, ',', 1));

        SET SubStrLen = CHAR_LENGTH(SUBSTRING_INDEX(_data_list_b, ',', 1))+2;
        SET _data_list_b = MID(_data_list_b, SubStrLen, strLen); --cut the 1st list item out

        IF _data_list_b = '' THEN
          LEAVE do_this;
        END IF;
      END LOOP do_this;

    COMMIT;
  END ;;
DELIMITER ;

Web Api中的代码

var url = 'https://accounts.google.com/o/oauth2/token';

var params = {
    client_id: req.body.clientId,
    redirect_uri: req.body.redirectUri,
    code: req.body.code,
    grant_type: 'authorization_code',
    client_secret: config.GOOGLE_SECRET
};

console.log(req.body.code);

request.post(url, {
    json: true,
    form: params
}, function (err, response, token) {
    var accessToken = token.access_token;
)};

我在node.js中有一个google身份验证代码,运行正常。当我尝试在wep-api的控制器中重写代码时,我得到一个错误的请求错误。 我哪里错了?有帮助吗? 注意:在两种情况下都完美设置了客户端ID和其他信息。

0 个答案:

没有答案