Open Closed

WPF & Xamarin Form Sample Project For ABP #578


User avatar
0
Leaf created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: vX.X.X
  • UI type: Angular / MVC
  • Tiered (MVC) or Identity Server Seperated (Angular): yes / no
  • Exception message and stack trace:
  • Steps to reproduce the issue:

Hi,

Do you have the demo or sample project for WPF & Xamarin Form to work with ABP ?

Thank you.


3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    We have a WPF template: https://github.com/abpframework/abp/tree/dev/templates/wpf. There is no xamarin project yet . see https://github.com/abpframework/abp/issues/158

  • User Avatar
    0
    Leaf created

    Hi @liangshiwei,

    due to some hardware sdk only work on .net framework, I have to comsume the web api in wpf .net framework.

    I hit the error for invalid_scope,

    Do you have the complete sample code for .net framework to call web api in wpf?

    Below is my code to get token and to call web api :-

    private async void DoTest()
    {
        //discover endpoints from metadata
       var client = new HttpClient();
    
        var disco = await client.GetDiscoveryDocumentAsync("https://localhost/");
        if (disco.IsError)
        {
            Console.WriteLine(disco.Error);
            return;
        }
    
        // request token
        var tokenResponse = await client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
        {
            Address = disco.TokenEndpoint,
            ClientId = "My_App",
            ClientSecret = "1q2w3e*",
            Scope = "Myapp"
        });
    
    
    
        if (tokenResponse.IsError)
        {
            Console.WriteLine(tokenResponse.Error);
            return;
        }
    
        Console.WriteLine(tokenResponse.Json);
        Console.WriteLine("\n\n");
    
        //// call api
        var apiClient = new HttpClient();
        apiClient.SetBearerToken(tokenResponse.AccessToken);
    
        var response = await apiClient.GetAsync("https://localhost:443/connect/token");
        if (!response.IsSuccessStatusCode)
        {
            Console.WriteLine(response.StatusCode);
        }
        else
        {
            var content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(JArray.Parse(content));
        }
    }
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    invalid_scope means you are missing some scope or the scope does not exists. check your database make sure Myapp is exists.

    invalid_scope usually has the following reasons:

    1. The scope does not exists , check IdentityServerApiScopes database table.
    2. The client does not include this scope, check IdentityServerClientScopes database table
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11