Open Closed

How to get current Client Id before user login #7507


User avatar
0
saad.aldulaijan created

I want to get the client id from this url

https://localhost:44322/Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3DAngular%26state%3DcU1ENEI5VVVhYU1jVzFhWlIyd0F4WkRoR3pMRGxJYng1dkNBQWJXdkFYfkVu%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4200%26scope%3Doffline_access%2520openid%2520AccountService%2520IdentityService%2520AdministrationService%2520SaasService%2520ProductService%2520NotificationService%2520FileManagement%26code_challenge%3DBpwCGKKxj8134IpedZFvbQgHGMXkTjugkkVFdwly88I%26code_challenge_method%3DS256%26nonce%3DcU1ENEI5VVVhYU1jVzFhWlIyd0F4WkRoR3pMRGxJYng1dkNBQWJXdkFYfkVu%26culture%3Den%26ui-culture%3Den

how to achieve this?

is there any service help me do that?


4 Answer(s)
  • User Avatar
    0
    saad.aldulaijan created

    I tried this one, gets null

    var request = HttpContext.GetOpenIddictServerRequest();
    
    var clientId = request?.ClientId; 
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can use the AbpOpenIddictRequestHelper to get OpenIddictRequest from ReturnUrl

    string returnUrl = request.Query["ReturnUrl"];
    var openIddictRequestHelper = httpContext.RequestServices.GetService<AbpOpenIddictRequestHelper>();
    var openIddictRequest = await openIddictRequestHelper.GetFromReturnUrlAsync(returnUrl);
    
  • User Avatar
    0
    saad.aldulaijan created

    hi

    You can use the AbpOpenIddictRequestHelper to get OpenIddictRequest from ReturnUrl

    string returnUrl = request.Query["ReturnUrl"]; 
    var openIddictRequestHelper = httpContext.RequestServices.GetService<AbpOpenIddictRequestHelper>(); 
    var openIddictRequest = await openIddictRequestHelper.GetFromReturnUrlAsync(returnUrl); 
    

    Hi

    How to get the returnUrl because this lines itself returns null var request = HttpContext.GetOpenIddictServerRequest();

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    The ReturnUrl exists on the request URL

    https://localhost:44322/Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3DAngular%26state%3DcU1ENEI5VVVhYU1jVzFhWlIyd0F4WkRoR3pMRGxJYng1dkNBQWJXdkFYfkVu%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4200%26scope%3Doffline_access%2520openid%2520AccountService%2520IdentityService%2520AdministrationService%2520SaasService%2520ProductService%2520NotificationService%2520FileManagement%26code_challenge%3DBpwCGKKxj8134IpedZFvbQgHGMXkTjugkkVFdwly88I%26code_challenge_method%3DS256%26nonce%3DcU1ENEI5VVVhYU1jVzFhWlIyd0F4WkRoR3pMRGxJYng1dkNBQWJXdkFYfkVu%26culture%3Den%26ui-culture%3Den

    string returnUrl = request.Query["ReturnUrl"]; 
    var openIddictRequestHelper = httpContext.RequestServices.GetService<AbpOpenIddictRequestHelper>(); 
    var openIddictRequest = await openIddictRequestHelper.GetFromReturnUrlAsync(returnUrl); 
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09