Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Options

Getting starting in C#

alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
Since I last was here, I figured out how to get the API keys.  Now I have downloaded from git OnshapeWindowsSample.   I set the environment variables as instructed here:
https://github.com/onshape-public/app-windows-sample
(Open question: the image says partner.dev.onshape.com, but the text says cad.onshape.com.  Which is right?).

When I run the C# console app, I get in the web browser the json below.  What do I need to do to get this working?  URL: https://oauth.onshape.com/oauth/authorize?response_type=code&client_id=....&&grant_type=authorization_code&redirect_uri=http://localhost:9326

{
  "moreInfoUrl" : "",
  "message" : "error=\"invalid_grant\", error_description=\"Application requested an invalid redirect URL http://localhost:9326\"",
  "status" : 400,
  "code" : 0
}

Creating knowledge-driven design automation software, for molds, etc.
www.virtualmold.com

Tagged:

Answers

  • Options
    alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    edited September 2020
    Ah, I discovered a distinction.  My app registration didn't use localhost:9326 as a redirect, but instead http://localhost/onshape-test.  Changing the sample app to use this alt url in both places got me to the Approve Onshape page.  Clicking approve on this however gets me to 

    Object not found!
    The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
    If you think this is a server error, please contact the webmaster.
    Error 404
    localhost
    Apache/2.4.37 (Win32) OpenSSL/1.1.1 PHP/7.2.12
    </code>So then I created a folder in my htdocs, called onshape-test, and I get:</pre></span><br><h1>Index of /onshape-test</h1><table><tbody><tr><th><img alt="ICO" src="http://localhost/icons/blank.gif"></th><th><a rel="nofollow" href="http://localhost/onshape-test/?C=N;O=D">Name</a></th><th><a rel="nofollow" href="http://localhost/onshape-test/?C=M;O=A" title="Link: http://localhost/onshape-test/?C=M;O=A">Last modified</a></th><th><a rel="nofollow" href="http://localhost/onshape-test/?C=S;O=A">Size</a></th><th><a rel="nofollow" href="http://localhost/onshape-test/?C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr><tr><td><img alt="PARENTDIR" src="http://localhost/icons/back.gif"></td><td><a rel="nofollow" href="http://localhost/">Parent Directory</a></td><td>&nbsp;</td><td class="post-text-align-right">-</td><td>&nbsp;</td></tr><tr><th colspan="5"><hr></th></tr></tbody></table><div>Apache/2.4.37 (Win32) OpenSSL/1.1.1 PHP/7.2.12 Server at localhost Port 80<br><br></div><pre class="CodeBlock"><code><div>Is there more to this test app or where do I go from here?</div><p></p>
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • Options
    alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    edited October 2020
    The result is I see this in the console:

    <div>Opening browser window for Onshape authentication...
    
    </div><div>Error: StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, 
    
    Content: System.Net.Http.StreamContent, Headers:
    
    </div><div>{
    
    </div><div>&nbsp; Connection: keep-alive</div><div>
    &nbsp; Strict-Transport-Security: max-age=31536000; includeSubDomains</div><div>
    &nbsp; X-Content-Type-Options: nosniff</div><div>
    &nbsp; X-XSS-Protection: 1; mode=block</div><div>
    &nbsp; Cache-Control: no-store, must-revalidate, no-cache</div><div>
    &nbsp; Date: Sat, 31 Oct 2020 13:48:10 GMT</div><div>
    &nbsp; Server: nginx</div><div>
    &nbsp; Content-Length: 55</div><div>
    &nbsp; Content-Type: application/json; charset=utf-8</div><div>
    }</div><div>
    Press any key to continue . . .</div><div></div>

    And that gets me to 
    http://localhost/onshape-test/?code=....

    but, onshape-test is a folder, not a program.  What am I missing?



    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

Sign In or Register to comment.