2017-05-16 10 views
0

anglejsを使用して 'https://connect.squareup.com/v2/locations'にリクエストを行い、403 FORBIDDENの呼び出しに失敗しました。ここでRequest Forbidden 403ローカルホストからのSquare-Connectへのリクエスト

は、コードサンプルです:

var url = 'https://connect.squareup.com/v2/locations'; 
     var config = { 
      headers: { 
       'Authorization': 'Bearer sandbox-sq0atb-JJGltCa375qzAyoQbjPgmg', 
       'Accept': 'application/json', 
       "X-Testing": "testing" 
      } 
     }; 
     $http.get(url, config) 
      .then(
       function (response) { 
        console.dir(response); 
       }, 
       function (response) { 
        console.log("failed" + response) 
       } 
      ); 

私は上記のサンプルのフィドルを行いました。どんな助けもありがとうございます。 XMLHttpRequest cannot load https://connect.squareup.com/v2/locations. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

http://jsfiddle.net/dx6tdrha/

+0

CORSの問題で実行しています。サーバー。 – anoop

答えて

1

あなたはこのエラーを見ていますか?これは、フロントエンドのJavascript(AngularJSなど)でAPIにアクセスできないことを意味します。Node.js、PHPなどの別の実装を使用する必要があります。

+0

はい。提案ありがとう。私はC#で実装しています。 –

+0

クライアントライブラリをチェックアウトしてください。https://github.com/square/connect-csharp-sdk/tree/release/2.1.0 – tristansokol

+0

これはC#で動作しました。 –