2016-11-03 5 views
0

私のウェブサイトのユーザーアカウントをpatreonに接続しようとしています。私はステップ3に応じてaccess_deniedエラーメッセージを受け取ります。私はこれに続いていますdocumentationNodeJS Patreon APIアカウントのリンク

マイノードサーバのコードは次のようになります。

socket.on("patreon_register",function(code,user){ 
     var reqString = "api.patreon.com/oauth2/token?code=" 
         +code 
         +"&grant_type=authorization_code&client_id=" 
         +settings.patreon.Client_ID 
         +"&client_secret=" 
         +settings.patreon.Client_Secret 
         +"&redirect_uri=" 
         +"http%3A%2F%2Fwww.levisinger.com%2F%3Fpage%3Dpatreon_success",       
     req = querystring.stringify({ 
      "code": code, 
      "grant_type": "authorization_code", 
      "client_id": settings.patreon.Client_ID, 
      "client_secret": settings.patreon.Client_Secret, 
      "redirect_uri": "http%3A%2F%2Fwww.levisinger.com%2F%3Fpage%3Dpatreon_success" 
      }), 
     post_options = { 
       host: 'api.patreon.com', 
       port: '80', 
       path: '/oauth2/token', 
       method: 'POST', 
       headers: { 
        'Content-Type': 'application/x-www-form-urlencoded', 
        'Content-Length': Buffer.byteLength(req) 
       } 
      };   
     // Set up the request 
     console.log(req); 
     var post_req = http.request(post_options, function(res) { 
      res.setEncoding('utf8'); 
      res.on('data', function (chunk) { 
       console.log(chunk); 
       if(
        chunk.access_token && 
        chunk.refresh_token && 
        chunk.expires_in && 
        chunk.scope && 
        chunk.token_type 
       ){ 
        Auth.linkPatreon(user,chunk,function(err,res){ 
         if(err){ socket.emit('patreon_register',false,res); } 
         else { socket.emit('patreon_register',true,res); } 
        }); 
       } 
      }); 
     }); 
     // post the data 
     post_req.write(req); 
     post_req.end(); 
    });  

実際にサーバに送信されますREQ変数は次のようになります(もちろん、一般的な値に私のコードを変更)

code=MY_RESPONSE_CODE&grant_type=authorization_code&client_id=MY_CLIENT_ID&client_secret=MY_CLIENT_SECRET&redirect_uri=MY_RESPONSE_URI 

任意のアイデア?最後に

+0

気にしない...私は前に行っていたステップの私が再でし全て、再コピーキーと、それは今働いています。 – Ethan

答えて

0

、私のサーバーは、次のようになりますし、働いている:

socket.on("patreon_register",function(code,user){ 
    var req = querystring.stringify({ 
      code: code, 
      grant_type: "authorization_code", 
      client_id: settings.patreon.Client_ID, 
      client_secret: settings.patreon.Client_Secret, 
      redirect_uri: settings.patreon.redirect_uri 
     }), 
    post_options = { 
      host: 'api.patreon.com', 
      port: '80', 
      path: '/oauth2/token', 
      method: 'POST', 
      headers: { 
       'Content-Type': 'application/x-www-form-urlencoded', 
       'Content-Length': Buffer.byteLength(req) 
      } 
     };   
    // Set up the request 
    console.log(req); 
    var post_req = http.request(post_options, function(res) { 
     res.setEncoding('utf8'); 
     res.on('data', function (chunk) { 
      chunk = JSON.parse(chunk); 
      console.log(chunk); 
      if(!chunk["error"]){ 
       console.log("Linking!"); 
       Auth.linkPatreon(user,chunk,function(err,res){ 
        if(err){ socket.emit('patreon_register',false,res); } 
        else { socket.emit('patreon_register',true,res); } 
        console.log("Linked!"); 
       }); 
      } 
     }); 
    }); 
関連する問題