Skip to content

bad or missing username when authenticating with Twitter #4291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
casajavi opened this issue Oct 25, 2017 · 4 comments
Closed

bad or missing username when authenticating with Twitter #4291

casajavi opened this issue Oct 25, 2017 · 4 comments

Comments

@casajavi
Copy link

Issue Description

I am trying to use the Twitter authentication through the Rest API and I keep receiving this error:

bad or missing username

I have set up the parse server with the necessary data as follows:

auth: {
   twitter: {
     consumer_key: "redacted",
     consumer_secret: "redacted"
   }
}

and I am sending a POST to /users with the following payload:

"authData": {
          "twitter": {
            "id": "12345678",
            "screen_name": "ParseIt",
            "auth_token": "redacted",
            "auth_token_secret": "redacted"
          }
        } 

I could not find any documentation detailing on how to achieve this and most of what I have tried has been from following the conversation on the PR by @flovilmart that added this functionality.

Maybe I am doing something wrong, if anyone has any suggestions I would appreciate it.

Steps to reproduce

The following command:

curl -X POST 
-H "X-Parse-Application-Id: redacted" 
-H "X-Parse-REST-API-Key: redacted" 
-H "X-Parse-Revocable-Session: 1" 
-H "Content-Type: application/json" 
-d '{
"authData": {
          "twitter": {
            "id": "12345678",
            "screen_name": "ParseIt",
            "auth_token": "redacted",
            "auth_token_secret": "redacted"
          }
        } 
}' 
http://myserver.com/users

Expected Results

A new parse user should be created

Actual Outcome

The following error is thrown: bad or missing username

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.5.3
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Google App Engine
  • Database mLab, ObjectRocket, Digital Ocean, etc): mLab

@flovilmart
Copy link
Contributor

flovilmart commented Oct 25, 2017 via email

@flovilmart
Copy link
Contributor

flovilmart commented Oct 25, 2017

@casajavi I just had a look at the source code, and the only way to get 'bad or missing username' error is to neither provide authData nor a username on this POST /users

This probably means that the payload is malformed, I managed to get this:

url -X POST \
  -H "X-Parse-Application-Id: redacted" \
  -H "X-Parse-REST-API-Key: redacted" \
  -H "Content-Type: application/json" \
  -d '{"authData":{"twitter":{"id":"12345678","screen_name":"ParseIt","auth_token":"redacted","auth_token_secret":"redacted"}}}' \
  http://localhost:1337/parse/users
{"code":101,"error":"Twitter auth is invalid for this user."}

So I guess that's probably the way your payload is formed/malformed.

@casajavi
Copy link
Author

@flovilmart Ok I wasn't including the correctly formatted payload but yea now I get the error you get.

{"code":101,"error":"Twitter auth is invalid for this user."}

now I am in the same spot hahaha.... so why is this error happening ?

Is this suppose to create a new user or only link twitter to an existing user?

@flovilmart
Copy link
Contributor

yeah so double check your auth_token, secret, and configuration. I believe there's an API explorer on twitter, so you can double check that all those parameters are valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants