Legacy Dev Forum Posts

 View Only

Sign Up

How get token to autenticate in C#

  • 1.  How get token to autenticate in C#

    Posted 06-05-2025 18:05

    MINNELLYJAKELINELU | 2018-12-14 22:21:41 UTC | #1

    I'm using this code to get the access token

    var clientId = ConfigurationManager.AppSettings.Get("clientId"); var clientSecret = ConfigurationManager.AppSettings.Get("clientSecret"); var encodedData = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(clientId + ":" + clientSecret)); var authorizationHeaderString = "Authorization: Bearer " + encodedData;

    but return me the code error: 401 (Unauthorized)


    Ronald_Tsang | 2018-12-17 05:23:26 UTC | #2

    Your code looks like it omits the Regional configuration of your purecloud environment. That might be your problem...


    tim.smith | 2018-12-17 15:28:17 UTC | #3

    You haven't provided any code that shows how you do the login or make use of the auth token, so I can't tell where you've gone wrong. 401 means you have not provided a valid auth token in your request. Any reason you're not using the .NET SDK to authenticate? It will handle authentication for you.


    MINNELLYJAKELINELU | 2018-12-17 16:16:09 UTC | #4

    I do not use .NET SDK because I have some problems:

    1. When I try to get the conversations the first time it does not return anything but in the second time there are conversations.
    2. Sometimes, when I download recordings, it shows me a 404 error, but if I try again the download works normally.

    tim.smith | 2018-12-17 16:19:01 UTC | #5

    Neither of those have anything to do with the SDK. I think we've discussed both of those things in other posts already. If not, look through recent posts because I know there have been posts about both recently.


    system | 2019-01-17 16:19:02 UTC | #6

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 4193