This topic contains 8 replies, has 2 voices, and was last updated by Muhammad Atif ✔ 5 years, 3 months ago.

  • Author
    Posts
  • #6530 Score: 0

    kentroylance
    • Contributions: 0
    • Level 1

    Where can I find this document:C# > RESTlet Authentication Using Token (Token-Based Authentication)

    This link does not take it to this document: https://netsuite.custhelp.com/app/an…ail/a_id/42169

    The link is found near the bottom of
    This is a cached copy. Click here to see the original post.

  • #6531 Score: 0

    chanarbon
    • Contributions: 0
    • Level 1

    Hi @kentroylance,

    I think the library on the link is the Google Code repository link for the OAuthbase.cs. Have you tried checking out this gist page: https://gist.github.com/ChanahC/3786…b1904fd2c1c354

    Please let me know if this sample works for your end. Thanks

  • #6532 Score: 0

    kentroylance
    • Contributions: 0
    • Level 1

    Even though this OAuthBase class is somewhat helpful, I was really hoping for a good c# example making a request using the following required fields:oauth_signature (required) – Credentials to verify the authenticity of the request, generated by calling your application. The Token Secret and Consumer Secret are constructed as a key to sign the request, using a supported signature method (HMAC-SHA1 or HMAC-SHA256).
    oauth_nonce (required) – Passes in a unique, random, alphanumeric string. String must be a minimum of 6 characters, and the maximum length is 64 characters. Used to verify that a request has never been made before.
    oauth_signature_method (required) – Must be set to HMAC-SHA1 or HMAC-SHA256. Declares which signature method is used.
    oauth_consumer_key (required) – Consumer Key (client application ID) generated for the token-based application in NetSuite. The unique value is matched to the token to establish ownership of the token.
    oauth_token (required) – Token ID generated for the token-based application in NetSuite.
    oauth_timestamp (required) – Passes in a positive integer expressed as the number of seconds since January 1, 1970 GMT.
    realm (required) – NetSuite company ID
    It would really be helpful if you had a web page for c# developers that was similar to this: https://netsuite.custhelp.com/app/an…ail/a_id/42168

    Thanks,

    Kent

  • #6533 Score: 0

    chanarbon
    • Contributions: 0
    • Level 1

    Hi kentroylance ,

    You should now be able to access it at https://netsuite.custhelp.com/app/an…ail/a_id/42169

  • #6534 Score: 0

    kentroylance
    • Contributions: 0
    • Level 1

    It is taking me to the Choose a Role web page. Are you seeing something different when you select this url? I added an attachment so you can see the page that this is being redirected to. I suspect this is the wrong link to the C# > RESTlet Authentication Using Token (Token-Based Authentication) example.

    Thanks,

    Kent

  • #6535 Score: 0

    chanarbon
    • Contributions: 0
    • Level 1

    Hi kentroylance ,

    For this concern, I would suggest you to first checkout SuiteAnswers and and search for 42169. Click the first link available and it should be leading you to the article. The scenario that you are experiencing is possible due to the fact that you haven’t initilized your SuiteAnswers session yet. So better start by going to SuiteAnswers from your NetSuite UI

  • #6536 Score: 0

    kentroylance
    • Contributions: 0
    • Level 1

    Looks like my origional problem of accessing the link to “C# > RESTlet Authentication Using Token (Token-Based Authentication) “; which, by the way is found in SuiteAnswers is finally working. Thanks!

  • #6537 Score: 0

    chanarbon
    • Contributions: 0
    • Level 1

    Yup. Just to ensure if ever somebody’s asking for a sample on it, I’ll post it in here as well.

    Code:
    Uri url = new Uri(“https://rest.netsuite.com/app/site/hosting/restlet.nl?script=992&deploy=1”);
    OAuthBase req = new OAuthBase();
    String timestamp = req.GenerateTimeStamp();
    String nonce = req.GenerateNonce();
    String ckey = “504ee7703e1871f22180441563ad9f01f3f18d67ecda580b0fae764ed7c4fd38”; //Consumer Key
    String csecret = “b36d202caf62f889fbd8c306e633a5a1105c3767ba8fc15f2c8246c5f11e500c”; //Consumer Secret
    String tkey = “080eefeb395df81902e18305540a97b5b3524b251772adf769f06e6f0d9dfde5”; //Token ID
    String tsecret = “451f28d17127a3dd427898c6b75546d30b5bd8c8d7e73e23028c497221196ae2”; //Token Secret
    String norm = “”;
    String norm1 = “”;
    String signature = req.GenerateSignature(url, ckey, csecret, tkey, tsecret, “GET”, timestamp, nonce, out norm, out norm1);
    //Percent Encode (Hex Escape) plus character
    if(signature.Contains(“+”)) {
    signature = signature.Replace(“+”, “%2B”);
    }
    String header = “Authorization: OAuth “;
    header += “oauth_signature=”” + signature + “”,”;
    header += “oauth_version=”1.0″,”;
    header += “oauth_nonce=”” + nonce + “”,”;
    header += “oauth_signature_method=”HMAC-SHA1″,”;
    header += “oauth_consumer_key=”” + ckey + “”,”;
    header += “oauth_token=”” + tkey + “”,”;
    header += “oauth_timestamp=”” + timestamp + “”,”;
    header += “realm=”ACCT123456″”;

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(“https://rest.netsuite.com/app/site/hosting/restlet.nl?script=992&deploy=1”);
    request.ContentType = “application/json”;
    request.Method = “GET”;
    request.Headers.Add(header);
    WebResponse response = request.GetResponse();
    HttpWebResponse httpResponse = (HttpWebResponse)response;

  • #26094 Score: 0

    Muhammad Atif ✔
    Member
    • Contributions: 1
    • Level 1
    @muhammad_atif

    Hi,

    I used the above code. But it returns error “The remote server returned an error: (403) Forbidden.”, I run the same restlet call in postman and it is working fine.  <span style=”color: #242729; font-family: Arial, ‘Helvetica Neue’, Helvetica, sans-serif; font-size: 15px;”>What is missing? Please help.</span>

     

You must be logged in to reply to this topic.