# ESI c#

**URL:** <https://forums.eveonline.com/t/esi-c/58888>\
**Category:** Third Party Developers\
**Created:** [February 21, 2018, 7:16pm UTC](https://forums.eveonline.com/t/esi-c/58888 "2018-02-21T19:16:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evelyne\_Obolensky](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/evelyne_obolensky/32/55973_2.png) [@Evelyne\_Obolensky](https://forums.eveonline.com/u/Evelyne_Obolensky)\
**Post date:** [February 21, 2018, 7:16pm UTC](https://forums.eveonline.com/t/esi-c/58888/1 "2018-02-21T19:16:14Z")

</div>

i try to change my little PI -Application from WindowsForm(API-XML) to Windows UWP ESI

Now i have a small Problem with SSO:

I can Login,  
Redirect want me to authorize my selected scopes (callback is a small HTTPListener)  
i authorize and get a code

Now i try to Exchange this Code into an access-token:

_ **\> // Create Jsondata for body** _  
_**\> var gt = new grant(Token);**_  
_**\> var jsondata = JsonConvert.SerializeObject(gt);**_  
_ **\> // new Webclient** _  
_**\> System.Net.WebClient wc = new System.Net.WebClient();**_  
_**\> // URI AUTHURL = “[https://login.eveonline.com/oauth/](https://login.eveonline.com/oauth/)”**_  
_**\> Uri uri = new Uri(Konstanten.AUTHURL + “token”);**_  
_ **\> // create Header Base64** _  
_ **\> var authcode = ClientID + “:” + SecretKey;** _  
_**\> var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(authcode );**_  
_**\> var aheader = System.Convert.ToBase64String(plainTextBytes);**_  
_\*\*\> \*\*_  
_\*\*\> \*\*_  
_**\> wc.Headers.Add(HttpRequestHeader.ContentType, “application/json”);**_  
_**\> wc.Headers.Add(HttpRequestHeader.Authorization, “Basic” + aheader);**_  
_ **\> // Post it** _  
_**\> var result = wc.UploadString(uri, jsondata);**_

It always get back on this step: The remote server returned an error: (401) Unauthorized.

Any hint to help me ?

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/blacksmoke16/32/376589_2.png) [@Blacksmoke16](https://forums.eveonline.com/u/Blacksmoke16)\
**Post date:** [February 21, 2018, 8:27pm UTC](https://forums.eveonline.com/t/esi-c/58888/2 "2018-02-21T20:27:53Z")

</div>

> [@Evelyne\_Obolensky](#):
>
> \> wc.Headers.Add(HttpRequestHeader.Authorization, “Basic” + aheader);

Part of the issue might be you need a space between `Basic` and your base64 encoded string.

---

<div class="post-metadata">

**Author:** ![Evelyne\_Obolensky](https://sea1.discourse-cdn.com/eveonline/user_avatar/forums.eveonline.com/evelyne_obolensky/32/55973_2.png) [@Evelyne\_Obolensky](https://forums.eveonline.com/u/Evelyne_Obolensky)\
**Post date:** [February 21, 2018, 10:00pm UTC](https://forums.eveonline.com/t/esi-c/58888/3 "2018-02-21T22:00:25Z")

</div>

correct !  
thanks for your hint!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/eveonline/original/3X/4/1/41ec4921cbaca7a6f9ea556e7cc20018461eae5e.png) [@system](https://forums.eveonline.com/u/system)\
**Post date:** [May 22, 2018, 10:00pm UTC](https://forums.eveonline.com/t/esi-c/58888/4 "2018-05-22T22:00:29Z")

</div>

Closed on May 22, 2018, 10:00pm UTC

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