Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9148601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:19:19+00:00 2026-06-17T11:19:19+00:00

I am writing a Web Api (using asp.net Web Api) and naturally want clients

  • 0

I am writing a Web Api (using asp.net Web Api) and naturally want clients to authenticate to use the service.

I was hoping to write a Javascript plugin that would make use of the Api and then make it available to be simply dropped into other web sites.

Is there a secure way I can have the plugin authenticate?
I’m not sure how I could keep any information passed to the plugin confidential.

I also want the API to be used by native apps, so does that rule anything making use of cookies?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:19:21+00:00Added an answer on June 17, 2026 at 11:19 am

    Is there a secure way I can have the plugin authenticate?

    You are going to have to either embed the username/password in your plugin OR have some fields to get that information from the user.

    Consider some code if you choose to embed the username/password:

    $.ajax({
            url: 'api/foo',
            type: 'GET',
            dataType: 'json',
            success: onSuccess,
            error: onError,
            beforeSend: setHeader
        });
    

    note the assignment of beforeSend to setHeader:

    function setHeader(xhr) {    
        xhr.setRequestHeader('Authorization', 'Basic YXBpX3VzZXIxOjEyMzQxMjM0');
    

    }

    Note, you will have to pre-calculate the auth string using the method below

    Now if you want to pull the username/password from the user you could do this:

    function setHeader(xhr) {            
            xhr.setRequestHeader('Authorization', make_base_auth($("#username").val(), $("#password").val()));
    }
    
    function make_base_auth(user, password) {
        var tok = user + ':' + password;
        var hash = Base64.encode(tok);
        return "Basic " + hash;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a simple proof-of-concept web service using ASP.NET MVC3 controller with JSON
I am writing a simple API using .Net's Web API. I have defined the
I'm writing a wrapper class for a third-party web service(SOAP) api. I want to
I am using Asp.Net Mvc Web api RC. I wanted to hide the fields/properties
I'm using ASP.NET Web API and I'm trying to return an instance of a
I'm writing a Web API service and trying to return a (400) Bad Request
I'm writing a web application using the google maps api v3, which displays places
I have a web application written in ASP .NET MVC 3. I'm using ACS
I am writing a Web API using MVC4 that should be consumed by multiple
I'm writing Web Service using perl 5.16.2, OAuth::Lite(1.31). Server is CentOS release 6.3 (Final),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.