"dipak.z" की गतिविधियाँ

उत्तर

Hii, Can you help me to find out solution of below error

{StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers: { Transfer-Encoding: chunked Server: Microsoft-IIS/10.0 X-Correlation-Id: eb76d290abe3420bb8465a61c5baf67a X-SourceFiles: =?UTF-8?B?RDpcQ29yZU1vZHVsZXNcQmFzZVByb2plY3RcVjhcU2dsQmFzZVByb2plY3Rcc3JjXFNnbEJhc2VQcm9qZWN0LldlYlxjb25uZWN0XHRva2Vu?= Date: Fri, 17 May 2024 11:18:49 GMT Content-Type: text/plain; charset=utf-8 }}

here is code

var response = await httpClient.Value.RequestPasswordTokenAsync(new PasswordTokenRequest { Address = disco.TokenEndpoint, ClientId = "SglBaseProject_Web", ClientSecret = "1q2w3e*", UserName = "admin", Password = "1q2w3E*", Scope = "openid offline_access email profile phone roles address SglBaseProject", }); if (response.IsError) throw new Exception(response.Error);

उत्तर

//Web Client var webClientId = configurationSection["SglBaseProject_Web:ClientId"]; if (!webClientId.IsNullOrWhiteSpace()) { var webClientRootUrl = configurationSection["SglBaseProject_Web:RootUrl"]!.EnsureEndsWith('/');

 /* SglBaseProject_Web client is only needed if you created a tiered
  * solution. Otherwise, you can delete this client. */
 await CreateApplicationAsync(
     name: webClientId!,
     type: OpenIddictConstants.ClientTypes.Confidential,
     consentType: OpenIddictConstants.ConsentTypes.Implicit,
     displayName: "Web Application",
     secret: configurationSection["SglBaseProject_Web:ClientSecret"] ?? "1q2w3e*",
     grantTypes: new List<string> //Hybrid flow
     {
         OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.Implicit
     },
     scopes: commonScopes,
     redirectUri: $"{webClientRootUrl}signin-oidc",
     postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc",
     clientUri: webClientRootUrl,
     logoUri: "/images/clients/aspnetcore.svg"
 );

}

उत्तर

using Microsoft.AspNetCore.Mvc.RazorPages; using IdentityModel.Client; using System.Net.Http; using System; using System.Threading.Tasks;

namespace SglBaseProject.Web.Pages { public class PortalModel : PageModel { const string server = "https://localhost:44363/"; public async void OnGet() { const bool setBearerToken = true;

        var httpService = new HttpService();
        var httpClient = await httpService.GetHttpClientAsync(setBearerToken);

        var response = await httpClient.Value.GetAsync(server+ "api/saas/tenants");
        response.EnsureSuccessStatusCode();
        var json = await response.Content.ReadAsStringAsync();
}

    public class HttpService
    {
        public async Task<Lazy<HttpClient>> GetHttpClientAsync(bool setBearerToken)
        {
            var client = new Lazy<HttpClient>(() => new HttpClient());
            var accessToken = await GetAccessToken();
            if (setBearerToken)
            {
                client.Value.SetBearerToken(accessToken);
            }
            client.Value.BaseAddress = new Uri(server); //
            return await Task.FromResult(client);
        }

        private static async Task<TokenResponse> GetTokensFromSglBaseProjectApi()
        {
            var authority = server;
            var discoveryCache = new DiscoveryCache(authority);
            var disco = await discoveryCache.GetAsync();
            var httpClient = new Lazy<HttpClient>(() => new HttpClient());
            var response = await httpClient.Value.RequestPasswordTokenAsync(new PasswordTokenRequest
            {
                Address = disco.TokenEndpoint,
                ClientId = "SglBaseProject_Web",
                ClientSecret = "1q2w3e*",
                UserName = "admin",
                Password = "1q2w3E*",
                Scope = "openid offline_access email profile phone roles address SglBaseProject",
            });
            if (response.IsError) throw new Exception(response.Error);
            return response;
        }

        private async Task<string> GetAccessToken()
        {
            var accessToken = (await GetTokensFromSglBaseProjectApi()).AccessToken;
            return accessToken;
        }

    }
}

}

उत्तर

getting error while executing below function

private static async Task<TokenResponse> GetTokensFromSglBaseProjecApi() { var authority = server; var discoveryCache = new DiscoveryCache(authority); var disco = await discoveryCache.GetAsync(); var httpClient = new Lazy<HttpClient>(() => new HttpClient()); var response = await httpClient.Value.RequestPasswordTokenAsync(new PasswordTokenRequest { Address = disco.TokenEndpoint, ClientId = "SglBaseProject_Web", ClientSecret = "1q2w3e*", UserName = "admin", Password = "1q2w3E*", Scope = "openid offline_access email profile phone roles address SglBaseProject", }); if (response.IsError) throw new Exception(response.Error); return response; }

Error:

ValueKind = Object : "{ "error": "unauthorized_client", "error_description": "This client application is not allowed to use the specified grant type.", "error_uri": "https://documentation.openiddict.com/errors/ID2064" }"

उत्तर

How to get access_token and how i can use it in postman or another environment

सवाल
  • ABP Framework version: 8.0.0
  • UI Type: MVC
  • Database System: EF Core PostgreSQL
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I want to call the tenent create api (/api/saas/tenants - post method) from postman or from another environment but it gives the 401 unauthorized .

उत्तर

i will check

  • ABP Framework version: v8.0.2
  • UI Type:MVC
  • Database System: EF Core (PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:
  • I want like if user subscribe in website then create tenant for that user's organization for specify time depends on package with specify max users creation for tenant. how can i do that? because tenant specific apis are permission based. i dont want to give that to user i want on successful payment for subscription

Any other way because portal is too slow when i put 1 minute

i have to solve because its show as vulnerability.

Thanks. I will run and test your project.

I Changed the code from Auto API Controller to HttpAPI Controller its working fine thanks.

58 प्रविष्टियों में 1 से 10 दिखा रहा है
Made with ❤️ on ABP v8.2.0-preview Updated on मार्च 25, 2024, 15:11