mustafa_m_hussein's blog

By mustafa_m_hussein, history, 6 months ago, In English

How to use Codeforces API to compose a request to use a person api key to authenticate that request.

I keep on getting the error : "You have to be authenticated to use this method".

Eg: "{u'status': u'FAILED', u'comment': u'apiKey: Incorrect signature;onlyOnline: You have to be authenticated to use this method'}"

if there anyone can help or give me an exapmle of request ?

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

You can read the documentation about authorization here...

  • »
    »
    6 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    i readey read it but i cant understand the example in the doc i need another one if u can give me an example this will be useful to me

    this my get request can u till me whats a problem here

    https://codeforces.com/api/contest.hacks?contestId=566&apiKey=0df9bea02d625273ee46121789a8ad208e957950&time={{currentdate}}&apiSig=123456#sha512Hex(123456/contest.hacks?apiKey=0df9bea02d625273ee46121789a8ad208e957950&contestId=566&time=1645028198#6bdd9677e7b082f143f541f981857e8b84b96e83)

    • »
      »
      »
      6 months ago, # ^ |
        Vote: I like it +30 Vote: I do not like it

      Thanks for posting your api key ;))

      • »
        »
        »
        »
        6 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        the API doesn't offer that much of valuable things to care about (I think!)

    • »
      »
      »
      6 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Do you actually calculate the sha512 hash or are you literally typing the words "sha512Hex" into the address?

      • »
        »
        »
        »
        6 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        no im just typing it how i calculat it ?

      • »
        »
        »
        »
        6 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        i used site to calculate and i put it like that https://codeforces.com/api/contest.hacks?contestId=566&apiKey=0df9bea02d625273ee46121789a8ad208e957950&time={{currentdate}}&apiSig=123456#5fcd23b1764dd55137604fcd84e53809e02356e27960e7e83f3cc88bf665f2b320031434ac7f151e22e6cc6a591766035ed4b5b279148d5d373f479a3dcc12e5

        its give me the same error whats wrong here ?

        • »
          »
          »
          »
          »
          6 weeks ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          You have to make all this within five minutes: 1. Prepare your link (and the hash part) except for the time and the hash 2. Get the time from any source, I suggest this site 3. Replace the time you copied from the site with the curly braces you have (both in the link and the hash part) 4. Hash the hash part with any function or site, for the convenience you can use this site 5. Concatenate the two parts on the address bar and hit enter 6. You have got the JSON

        • »
          »
          »
          »
          »
          6 weeks ago, # ^ |
          Rev. 2   Vote: I like it 0 Vote: I do not like it

          I wrote a friend 's visualiser through javascript which was on a similar line as yours, so I guess it would be enough for you to understand what' s wrong with your way of handling it.

          var APIkey = document.getElementById("ak").value;

          var secret = document.getElementById("skey").value;

          var code = "936854/user.friends?apiKey=" + APIkey + "&onlyOnline=false&time=" + time + "#" + secret;

          code = SHA512(code); //Convert to SHA hash

          //time: time in unix format, remember to have it at max less than 5 minutes only

          var base_url = "https://codeforces.com/api/user.friends?apiKey=" + APIkey + "&onlyOnline=false&time=" + time + "&apiSig=936854" + code;

          • »
            »
            »
            »
            »
            »
            6 weeks ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            ty its help : )

          • »
            »
            »
            »
            »
            »
            6 weeks ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            I have gone through the whole API documentation and have found nothing about getting data from inside groups even if you have the authority to do

            Have you scored any advances in this direction?

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

nice api