Forum Topic - FRCAPI 401 Unauthorized - Username Not Found: (16 Items)
   
FRCAPI 401 Unauthorized - Username Not Found  
I get a 401 response code with "Username Not Found" with every request I make, both on the test and the production 
server.

I'm providing an Authorization field, which I generated like this:

    echo Basic $(echo -n 'ThomasClark:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' | base64)

And this is what my code looks like:

    try:
        req = urllib2.Request('https://frc-staging-api.usfirst.org/api/v1.0/2014')
        req.add_header('Authorization', authorization_token)
        req.add_header('Accept', 'application/json')
        print json.load(urllib2.urlopen(req))
    except urllib2.HTTPError, e:
        raise Exception('{} {} - {}'.format(e.code, e.msg, e.fp.read()))

Any ideas?
Re: FRCAPI 401 Unauthorized - Username Not Found  
I am having the same issue. 
Re: FRCAPI 401 Unauthorized - Username Not Found  
My solution (in Java) is working fine:

            String clearAuth = "Username:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
            String encodedAuth = new String(Base64.encodeBase64(clearAuth.getBytes()));

            connection.setRequestProperty  ("Authorization", "Basic " + encodedAuth);

From what you posted, it looks like you need to prepend "Basic " to the encoded authorization token before attaching it 
to the request.
Re: FRCAPI 401 Unauthorized - Username Not Found  
I'm not sure that's true.  There's a separate response for invalid authorization ("Unable To Determine Authorization 
Token").  According to the docs, the "Username Not Found" response happens when the format is correct but the username 
isn't on file.

I'm not sure about Kyle, but you'll also notice in my original post that I did include "Basic ", so that's not the 
problem.
Post Deleted
Re: FRCAPI 401 Unauthorized - Username Not Found  
The following bash alias works for me

alias frc-api="curl --header \"Authorization: Basic $(echo -n 'user:token ' | base64)\""
Re: FRCAPI 401 Unauthorized - Username Not Found  
I just tested the username / token emailed to me with this, and it returns "Username Not Found".
-Alan
Re: FRCAPI 401 Unauthorized - Username Not Found  
I'm also having the same issue. I received an email with my API key on 2015/03/02. I'm fairly certain I've encoded the 
username / key combination correctly.
Re: FRCAPI 401 Unauthorized - Username Not Found  
My authentication code was working yesterday, and today I am getting 401 Unauthorized.  I have not changed the code 
which generates the authentication string in over a week.
Re: FRCAPI 401 Unauthorized - Username Not Found  
Hi Duane, please contact me directly for support (the message you are receiving should have said this as well). Your 
token was blocked for excessive use.
Re: FRCAPI 401 Unauthorized - Username Not Found  
When I try to use the API with my new key in PHP I get the following string return:

string 'Username Not Found' (length=18)

This is how I encode my Authorization Token:

$auth = "Authorization: Basic " . base64_encode(Username:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX);

Clearly the encoding is working because the Docs say that whenever this error is returned that the api 'finds' a decoded
 username, but that that username is not actually registered.

Is it possible that anyone recently added to the API token list may not be added on the API side yet?

Thanks
Re: FRCAPI 401 Unauthorized - Username Not Found  
It seems unlikely that it has to do with being added recently.  I got my token four days ago, and it still doesn't work.
  I'm just speculating, though - it's impossible to tell until someone from FIRST speaks up.
Re: FRCAPI 401 Unauthorized - Username Not Found  
> It seems unlikely that it has to do with being added recently.  I got my token
>  four days ago, and it still doesn't work.  I'm just speculating, though - 
> it's impossible to tell until someone from FIRST speaks up.

I'm not sure either, but I also got my token 4 days ago.

> Are you using the staging API (frc-staging-api.usfirst.org) or the production 
> one? (frc-api.usfirst.org)

Regardless of which one I use, I get the same error.

Re: FRCAPI 401 Unauthorized - Username Not Found  
Are you using the staging API (frc-staging-api.usfirst.org) or the production one? (frc-api.usfirst.org)
Re: FRCAPI 401 Unauthorized - Username Not Found  
I've sent a direct email to you.
Re: FRCAPI 401 Unauthorized - Username Not Found  
Hi everyone,
It appears that certain usernames we receive from TeamForge come with a carriage return character added to the end of 
them- hence not being able to find that username on an API request. If you are having trouble with your username, please
 send me a direct email and we will double check it.
I think everyone who commented on this thread we have already replied to directly via email- so please check that first.

Thanks