title: Receving access token from api with oauth in c#
body: <p>I want to use <a href="https://docs.newsletter2go.com/?_ga=2.101770945.1383055912.1507036279-1320900446.1507036279" rel="nofollow noreferrer">Newsletter2Go API</a>. I've downloaded a c# example, added the compiled library and tried to getting started with receiving a access token. I'm new to programming with a REST-API but as far as I've understand I need to connect with my api-key and credentials to receive the access token. With the token I can do further operations.</p>
  <p>This is the code for receving the token.</p>
  <pre><code>        //////// Configure HTTP basic authorization: Basic
          Configuration.Default.Username = &quot;&quot;;
          Configuration.Default.Password = &quot;&quot;;
         
          var apiInstance = new AuthorizationApi();
          var grantType = &quot;&quot;;  // string | grant_type (default to https://nl2go.com/jwt)
          var username = &quot;&quot;;  // string | username. Required for grant_type https://nl2go.com/jwt (optional) 
          var password = &quot;&quot;;  // string | password. Required for grant_type https://nl2go.com/jwt (optional) 
          var refreshToken = &quot;&quot;;  // string | refresh_token. Required for grant_type https://nl2go.com/jwt_refresh (optional) 
  
          try
          {
              // Endpoint for retrieving a token
              Token result = apiInstance.GetToken(grantType, username, password, refreshToken);
              Debug.WriteLine(result);
          }
          catch (Exception ex)
          {
              Debug.Print(&quot;Exception when calling AuthorizationApi.GetToken: &quot; + ex.Message);
          }
  </code></pre>
  <p>I get the error.</p>
  <blockquote>
  <p>Exception when calling AuthorizationApi.GetToken:</p>
  <p>Error calling GetToken: {&quot;error&quot;:&quot;invalid_client&quot;,&quot;error_description&quot;:&quot;The client credentials are invalid&quot;}</p>
  </blockquote>
  <p>I don't understand how I can pass the api-key to the api. In the docs they write this but there is no examplel in c# in the docs.</p>
  <pre><code>...and add an Authorization header with your auth key:
  xhr.setRequestHeader(&quot;Authorization&quot;, &quot;Basic &quot; + btoa(&quot;xhr5n6xf_Rtguwv_jzr1d3_LTshikn4_0dtesdahNvp1:Kqf2Hs#Wwazl&quot;);
  send the request:
  xhr.send(JSON.stringify(params));
  </code></pre>
  <p>So any ideas what's missing here? Thanks in advance.</p>