1

私は何かを検索して見つけましたが、完全な文書はありませんhereIdentityServer3でホストされているIdentity Manager APIにリモートからアクセスする方法は?

誰かが私にステップの説明でステップを教えてください。

IdentityServer3の設定が整っており、ブラウザからIdentityManagerにアクセスしてユーザを完全に管理できることが確認されています。今、ユーザーを管理する必要がありますが、別のカスタムアプリケーションから管理しています。だから私は行う必要があります。カスタムアプリ

    1. ログインIdmのAPIを介してユーザーを管理します。

    私は「ResourceOwner」助成金を使用してアクセストークンを取得するために「IDMGR」スコープを使用しています:https://localhost:44376/ids/connect/tokenを。

    しかし、私はhttps://localhost:44376/idm/api/users?count=10&start=0にアクセスするには、そのトークンを使用する場合、私はメッセージ"Authorization has been denied for this request."

  • +0

    が正しい役割の請求がログインしているユーザーのために設定されているかを取得? http://stackoverflow.com/questions/35677334/secure-identitymanager-with-identityserver3/ – rawel

    +0

    @rawel私は2人のロール "Administrator"と "IdentityManagerAdministrator"を持っています。このユーザー用に設定しました –

    +1

    これはこれまでに実現しましたか? –

    答えて

    0
     var client = new HttpClient(); 
         var dic = new Dictionary<string, string>(); 
         dic.Add("client_id", "mvc"); 
         dic.Add("client_secret", "secret"); 
         dic.Add("grant_type", "password"); 
         dic.Add("scope", "openid profile"); 
         dic.Add("username", "[email protected]"); 
         dic.Add("password", "[email protected]"); 
    
         var content = new FormUrlEncodedContent(dic); 
    
         var msg = client.PostAsync("https://localhost:44383/identity/connect/token", content).Result.Content.ReadAsStringAsync().Result; 
         string token = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(msg).access_token; 
    
         var jwt = new JwtSecurityToken(token); 
         var identity = new ClaimsIdentity("ApplicationCookie", ClaimsIdentity.DefaultNameClaimType, ClaimsIdentity.DefaultRoleClaimType); 
         foreach (var c in jwt.Claims) 
         { 
          var t = c.Type; 
          var v = c.Value; 
    
          identity.AddClaim(new Claim(t, v)); 
    
         } 
          IAuthenticationManager authenticationManager = HttpContext.GetOwinContext().Authentication; 
          authenticationManager.SignOut("ApplicationCookie"); 
          authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = false }, identity); 
    
         return Redirect("Index"); 
    
    関連する問題