0
votes

I am new to Microsoft graph so this might be a dumb question. So I am writing a command line application trying to update a page in our team onenote. (enterprise onenote) Here is the code I got work getting the token. https://login.microsoftonline.com/common/oauth2/authorize?client_id=my_client_Id&response_type=code&redirect_uri=Some_uri&resource=https://graph.microsoft.com&scope=Notes.ReadWrite.All

I got the token as strCode and trying to retrieve all the notes under this account by these codes:

    var baseAddress = new Uri("https://graph.microsoft.com/v1.0/me/onenote");

    using (var httpClient = new HttpClient { BaseAddress = baseAddress })       
    {
        var request = new HttpRequestMessage(HttpMethod.Get, @"/pages");
        request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", strCode);

        using (var response = httpClient.SendAsync(request).Result)
        {
            string responseData = response.Content.ReadAsStringAsync().Result;
        }
    }

And in the response data I got "{ \"error\": { \"code\": \"InvalidAuthenticationToken\", \"message\": \"CompactToken parsing failed with error code: -2147184105\", \"innerError\": { \"request-id\": \"*********************", \"date\": \"2017-06-08T18:25:06\" } } }"

Any idea how to fix this..?

1

1 Answers

1
votes

Problem resolved . I need to convert the authentication code into a "real" access token.. The one that I got is not an access token.