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

  • Home
  • SEARCH
  • 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 7531931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:18:26+00:00 2026-05-30T05:18:26+00:00

I’ve read about oAuth, Amazon REST API, HTTP Basic/Digest and so on but can’t

  • 0

I’ve read about oAuth, Amazon REST API, HTTP Basic/Digest and so on but can’t get it all into “single piece”. This is probably the closest situation – Creating an API for mobile applications – Authentication and Authorization

I would like to built API-centric website – service. So (in the beginning) I would have an API in center and website (PHP + MySQL) would connect via cURL, Android and iPhone via their network interfaces. So 3 main clients – 3 API keys. And any other developer could also develop via API interface and they would get their own API key. API actions would be accepted/rejected based on userLevel status, if I’m an admin I can delete anything etc., all other can manipulate only their local (account) data.

First, authorization – should I use oAuth + xAuth or my some-kind-of-my-own implemenation (see http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/RESTAuthentication.html?r=9197)? As I understand, on Amazon service user is == API user (have API key). On my service I need to separate standard users/account (the one who registered on the website) and Developer Accounts (who should have their API key).

So I would firstly need to authorize the API key and then Authenticate the user itself. If I use Amazon’s scheme to check developer’s API keys (authorize their app), which sheme should I use for user authentication?

I read about getting a token via api.example.org/auth after (via HTTPS, HTTP Basic) posting my username and password and then forward it on every following request. How manage tokens if I’m logged in simultaneously on Android and a website? What about man-in-the-middle-attack if I’m using SSL only on first request (when username and password are transmitted) and just HTTP on every other? Isn’t that a problem in this example Password protecting a REST service?

  • 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-30T05:18:27+00:00Added an answer on May 30, 2026 at 5:18 am

    As allways, the best way to protect a key is not to transmit it.

    That said, we typically use a scheme, where every “API key” has two parts: A non-secret ID (e.g. 1234) and a secret key (e.g. byte[64]).

    • If you give out an API key, store it (salted and hashed) in you
      service’s database.
    • If you give out user accounts (protected by password), store the
      passwords (salted and hashed) in your service’s database

    Now when a consumer first accesses your API, to connect, have him

    • Send a “username” parameter (“john.doe” not secret)
    • Send a “APIkeyID” parameter (“1234”, not secret)

    and give him back

    • the salts from your database (In case one of the parameters is wrong,
      just give back some repeatable salt – eg.
      sha1(username+”notverysecret”).
    • The timestamp of the server

    The consumer should store the salt for session duration to keep things fast and smooth, and he should calculate and keep the time offset between client and server.

    The consumer should now calculate the salted hashes of API key and password. This way the consumer has the exact same hashes for password and API key, as what is stored in your database, but without anything seceret ever going over the wire.

    Now when a consumer subseqently accesses your API, to do real work, have him

    • Send a “username” parameter (“john.doe” not secret)
    • Send a “APIkeyID” parameter (“1234”, not secret)
    • Send a “RequestSalt” parameter (byte[64], random, not secret)
    • Send a “RequestTimestamp” parameter (calculated from client time and known offset)
    • Send a “RequestToken” parameter (hash(passwordhash+request_salt+request_timestamp+apikeyhash))

    The server should not accept timestamps more than say 2 seconds in the past, to make this safe against a replay attack.

    The server can now calculate the same hash(passwordhash+request_salt+request_timestamp+apikeyhash) as the client, and be sure, that

    • the client knows the API key,
    • the client knows the correct password
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

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.