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 6729665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:19:03+00:00 2026-05-26T10:19:03+00:00

So I have this idea for a very simple service that will provide an

  • 0

So I have this idea for a very simple service that will provide an API and I know how to write REST-ish APIs in PHP but everything I ever done has been freely accessible. For this one I’d like to provide access via either a key/secret pair or basic http auth.

I have no idea how to do either.

  • 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-05-26T10:19:04+00:00Added an answer on May 26, 2026 at 10:19 am

    It all works through HTTP headers in some form or another. A normal login procedure usually uses cookies, so there’s the request header Cookie: FOO=owiegwoeugiaweg being sent which the server picks up on. You can do the same for APIs, but it’s not usually the best thing to do.

    Better is some form of authorization using certain header fields like the Authorization header:

    Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
    

    This header can contain anything you want. You can use some custom password hashing/key exchange/whatever algorithm and require the client to send this information in the Authorization header. You could also come up with any custom header of your own, if you like.

    A good way to RESTfully authenticate requests is to use request signing. The algorithm for that is up to you, but should include at least the current time, the request body and a user specific key, which is hashed together to form a signature.

    headers:
        Date: Thu, 20 Oct 2011 04:00:48 GMT
        Authorization: MySchema user123:oiquwetfp32900fjp0q93t1039
    
    where:
        Date          = timestamp, must be within 15 mins of server time
        Authorization = MySchema USERNAME:SIGNATURE
        SIGNATURE     = sha1( Date + REQUEST BODY + PASSKEY )
    

    This way you’re essentially sending the user’s passkey with every request, but scrambled in a way that’s non-reversible, unique for every request, yet confirmable by the server by repeating the same operations (checking for valid timestamp, hashing the Date header + request body + user’s passkey). There used to be good documentation that explained this process in detail for Amazon Web Services, but I can’t find it right now. Try researching “request signing” for more information.

    On the server side you can find these HTTP headers in the $_SERVER array. The raw request body you can get via file_get_contents('php://input').

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have no idea what is wrong! This is a very simple program and
The idea it's very easy, i have an http download class, this class must
I have a html like this: The idea is that divs are floated left
I have no idea what this means. But here is the code that it
I have a very simple javascript class that does an ajax call to a
This is probably a very simple and stupid question to ask, but I have
I have a very very simple SQL string that MS Access doesn't seem to
I am currently developing a very simple web service and thought I could write
I have this very simple form: <form id=header_search><input type=text value=search></form> and this is my
I have this grand idea to basically employ some brute force attack to test/verify

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.