Legacy Dev Forum Posts

 View Only

Sign Up

OAuth for C# Application without Login Prompt

  • 1.  OAuth for C# Application without Login Prompt

    Posted 06-05-2025 18:11

    hclix81 | 2017-01-03 16:56:16 UTC | #1

    I'm wanting to build a C# application to get call conversation details without having to prompt a login so I can execute without someone manually having to run the program. Is this possible? So far I can authenticate using a C# app but can't access conversation details as I get a 403 error. Or I can authenticate with a web form pop up and can access the conversation details API calls. Is what I'm attempting possible? If so is there an example I can look at?


    tim.smith | 2017-01-03 17:05:44 UTC | #2

    hclix81, post:1, topic:760
    can't access conversation details as I get a 403 error

    What API resource are you using? And what task are you trying to accomplish?

    If you need to have a user context, like when using GET /api/v2/conversations, you must have a user log in. There is no way for an auth token to have a user context without a user logging in via the implicit or auth code OAuth flows. The easiest way to have a user log in to a .NET desktop app is to use the .NET OAuth Control. Documentation and examples are in the repo.

    If you don't need a user context, like when using POST /api/v2/analytics/conversations/details/query, you can use the Client Credentials OAuth flow. This will allow the application to authenticate using only a client ID and client secret, but the access token won't have a user context. If you're getting a 403 with client credentials, the oauth client needs additional permissions granted to it.


    hclix81 | 2017-01-03 17:43:53 UTC | #3

    I'm attempting to get /api/v2/analytics/conversations/details/query

    Below is my code giving the 403 not authorized error. I've removed my clientid and secret. I'm able to connect to other APIs but not this one or "CallConversationEntityListing result = apiInstance.GetCallsHistory"

    var accessTokenInfo = Configuration.Default.ApiClient.PostToken("", "", "", "");

    ININ.PureCloudApi.Client.Configuration.Default.AccessToken = accessTokenInfo.AccessToken; var apiInstance = new AnalyticsApi(); var body = new ConversationQuery(); // ConversationQuery | query

    try { // Query for conversation details AnalyticsConversationQueryResponse result = apiInstance.PostConversationsDetailsQuery(body); //Debug.WriteLine(result); } catch (Exception g) { //Debug.Print("Exception when calling AnalyticsApi.PostConversationsDetailsQuery: " + e.Message); }


    tim.smith | 2017-01-03 18:02:06 UTC | #4

    AnalyticsConversationQueryResponse result = apiInstance.PostConversationsDetailsQuery(body);

    If that's what's throwing a 403, your access token lacks permissions.

    <img src="//inin-prod-use1-developerforum.s3.amazonaws.com/original/1X/b5e41a8394c506a6fce435cc5d6a8ca530158020.png" width="690" height="251">

    CallConversationEntityListing result = apiInstance.GetCallsHistory

    That should be throwing a different error because call history requires a user context and you're using client credentials.


    hclix81 | 2017-01-03 18:33:11 UTC | #5

    Alright so I'm getting a 400 error now for interval is required. Before I dig into that I want to make sure I'm looking at the right API call. What I want to do is get conversation data or call history to be able to push the output back into our SQL system for reporting. Will the PostConversationsDetail return that information to me like the /api/v2/analytics/conversations/details/query does using the developer tools or should I be using a different procedure?


    tim.smith | 2017-01-03 18:36:53 UTC | #6

    hclix81, post:5, topic:760
    Will the PostConversationsDetail return that information to me like the /api/v2/analytics/conversations/details/query does using the developer tools or should I be using a different procedure?

    That's the best approach to developing analytics queries. Build them in the developer tools to get them the way you want them and then replicate the query in your code with the SDK.


    system | 2017-08-28 19:29:41 UTC | #7


    This post was migrated from the old Developer Forum.

    ref: 760