Starts in:
2 DAYS
5 HRS
33 MIN
44 SEC
Starts in:
2 D
5 H
33 M
44 S
Open Closed

Microsoft access token in custom api #589


User avatar
0
sammy@projile.com 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: v3.2.1
  • UI type: Angular
  • Tiered (MVC) or Identity Server Seperated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:
  • I have enabled microsoft login in angular application. I am able to login and view my dashboard. Now i need the microsoft accessToken in my custom api to call the microsoft API (power automate API). Please help how i can get accessToken in my custom api.

My API Code:

        var client = new RestClient(url);
        
        client.AddDefaultHeader("Authorization", **accessToken**);
        client.AddDefaultHeader("Content-Type", "application/json");
        client.AddDefaultHeader("Accept", "application/json");

        return client;

3 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    if your client is a C# client then it's easy. Share the HttpApi.Client project with your custom client and call your API endpoints without using a RestClient. There's a sample app in your solution. Go to test folder in your root path of your solution. Find *.HttpApi.Client.ConsoleTestApp. It makes a request to gets user profile (which requires authentication). The authentication credentials must be given in appsettings.json file

  • User Avatar
    0
    shobhit created

    Hello Alper, my service is in "Project.Application" module itself. I have created my module called "Workflowservice". Within "Workflowservice" api method i am calling microsoft api to get the data. Now to call Microsoft api i need current signed-in user microsoft access token so that i can call api on the behalf of logged in user.

    Angular UI --> ABP API (Workflowservice Module in "myproject.Application" --> Get Data method --> microsoft api)
    
  • User Avatar
    0
    alper created
    Support Team Director

    check out this https://support.abp.io/QA/Questions/560/How-can-I-call-an-ABP-remote-service-method very similar question

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06