Forum Discussion

smeetsh's avatar
smeetsh
Continued Contributor
2 years ago
Solved

Passing a bearer token to copy data action using GET

Hi All,

 

Not a question, but something I ran into, as I am just picking up MS Fabric, pipelines etc.

I needed to use web request, to get an access token that is valid for 30 minutes. Next I needed to use that token as a bearer token to do a follow up API call to get actual data , there didn't seem to be that much info around, when I tried to google it. Eventually I found a you tube video, that told me what i needed to know. (linked below). Things like apikeys and other credentials will of course vary on the API yo are trying to use.

 

This is my flow.


Step 1 
Do your web request

 

Step 2 link the Web and copy data action

 

Step 3 In the copy data action  set it up as follows:

As you can see the value of the Authorization header is dynamic, with in my case, the following expression:

Bearer @{activity('Get access token').output.access_token}

The part ".access_token" depends on the json you get returned, in my case it was a very flat structure with no above array.
{
    "token_type": "BearerToken",
    "issued_at": "xxx",
    "salesforce_id": "xxx",
    "access_token": "xxx",
    "application_name": "xxx",
    "scope": "refresh_token full",
    "expires_in": "xxx"
}

Above you can see where i got the parameter access_token from. If this array had been nested in for instance another array called  "data" then the value would have been data.access_token in stead of just access_token.

I hope this is usefull info to share here. The video I got this from you can find here .

Cheers

Hans




 

  • smeetsh's avatar
    smeetsh
    2 years ago

    Good morning,

    Yes just sharing knowledge, since it wasn't so straightforward to find as I thought it would be

     

    Cheers

    Hans

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi smeetsh ,

    Thanks for using Fabric Community. 
    Can you please confirm whether this is a question or just sharing the knowledge across the Community?
    As I understand you are just sharing the knowledge across the Community.

    • smeetsh's avatar
      smeetsh
      Continued Contributor

      Good morning,

      Yes just sharing knowledge, since it wasn't so straightforward to find as I thought it would be

       

      Cheers

      Hans

  • You should not put a token in directly, instead use @concat('Bearer ', activity('Get Auth Token').output.access_token)

    • smeetsh's avatar
      smeetsh
      Continued Contributor

      Which is exactly what id did