Reputation: 1178
I am developing an JavaScript app to create work items in Visual Studio Team Services (was Visual Studio Online). But While authenticating I am getting the below error.
{"Error":"unauthorized_client","ErrorDescription":null}
I don't want to write any C# code so I am doing it all on html/javascript way. I am getting the Auth_Code but access_token.
<form method="post" action="https://app.vssps.visualstudio.com/oauth2/token? redirect_uri=http://mycallbackurl" id="accesstoken" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="client_assertion_type" value="urn:ietf:params:oauth:client-assertion-type:jwt-bearer" />
<input type="hidden" id="client_assertion" name="client_assertion" value="appSecret" />
<input type="hidden" name="grant_type" value="urn:ietf:params:oauth:grant-type:jwt-bearer" />
<input type="hidden" id="assertion" name="assertion" value="auth_code" />
I am submitting the above form and In that I am getting this error. I have even tried to do the same using $.ajax but the same result.
Please help me in this.
Upvotes: 0
Views: 573
Reputation: 1580
You cannot send a authorize users via client side code as per the FAQ on the Auth page of the API documention.
Q: Can I use OAuth with my phone app?
A: No. Right now, Visual Studio Team Services only support the web server flow, so there's no supported way to implement OAuth for Visual Studio Team Services from an app like a phone app, since there's no way to securely store the app secret.
https://www.visualstudio.com/en-us/integrate/get-started/auth/oauth
You have to do the OAuth handshake via server side code.
Upvotes: 2