2016-11-15 4 views
0

私はidentityServer3サンプルアプリケーションを持っています。IdentityServer3 ResourceOwner角度リクエストから400が返されます。不正リクエスト

public static IEnumerable<Client> GetClients() 
     { 
      return new[] 
        { 
         new Client 
         { 
          Enabled = true, 
          ClientId = "manager", 
          ClientName = "ManagerIdentity", 
          Flow = Flows.ResourceOwner, 
          ClientSecrets = new List<Secret> 
          { 
           new Secret("secret".Sha256()) 
          }, 
          AllowedScopes = new List<string> 
          { 
           Constants.StandardScopes.OpenId 
          }, 
          AllowAccessTokensViaBrowser = true, 
          AllowedCorsOrigins = new List<string>{ 
           "http://localhost:24678/" // angular application uri 
          } 
         } 
      } 

私は郵便配達員とトークンリターンでこの情報を使用しています。

enter image description here

しかし、私はそれが400不正な要求を返すangularjs javascriptのアプリケーションを介して同じ要求を送信します。

angular.module("app").controller("ROPCController", [ 
    "$scope","$http", 
    function($scope,$http) { 

     $scope.login = function() { 


      var options = { 
       "url": "http://localhost:4751/connect/token", 
       "method": "POST", 
       "data": { 
        "username": "muser", 
        "password": "password", 
        "grant_type": "password", 
        "client_id": "manager", 
        "client_secret": "secret", 
        "scope":"openid" 
       }, 
       "headers": { 
        "Content-Type": "application/x-www-form-urlencoded" 
       } 
      }; 

      $http(options).then(
       function(response) { 
        console.log(response.data); 
       }, 
       function(error) { 
        console.log(error); 
       } 
      ); 
     } 
    } 
]); 

{「エラー」:「invalid_client」}

答えて

0

あなたのデータはJSON形式であるので、あなたのapplication/jsonにコンテンツタイプを変更したり、username=muser&password=password&...

にデータの形式を変更する必要があります

これが役に立ちます。

+0

私は、アプリケーション/ jsonコンテンツタイプが「415サポートされていないメディアタイプ」 – barteloma

+0

を返すようにしました。データフォーマットを「データ」のような文字列に変更しようとしましたか?「username = muser&password = password&grant_type = password&...」 "Content-Type": "application/x-www-form-urlencoded"? – hakany

+0

okしてくれてありがとう。 – barteloma

関連する問題