Skip to content
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

Undefined index "user_id" #24

Open
roberttolton opened this issue Jan 9, 2019 · 4 comments
Open

Undefined index "user_id" #24

roberttolton opened this issue Jan 9, 2019 · 4 comments

Comments

@roberttolton
Copy link

Hi, thanks for this library - it's working fine for the first user (me), but any subsequent users that try and authenticate with my app are met with an Undefined index "user_id" error from AdamPaterson\OAuth2\Client\Provider\SlackAuthorizedUser->getId().

I can't figure out why it would be successful for one user (me, the one who installed the App into the Workspace) and not for other users?

When I look at $token from $provider->getAccessToken() the scopes are a bit different:

From a flow that worked:
identify,commands,incoming-webhook,channels:read,groups:read,users:read,identity.basic,identity.email,identity.avatar,identity.team

From a flow that didn't work:
identity.basic,identity.email,identity.avatar,identity.team

But the JSON that this scope data comes from, from Slack, is shown as ok and even has the accessToken in the response - it's not like there's a user_id property existing in one and not the other, so I'm kind of at a loss as to which point in the flow the user_id index is missing.

@roberttolton
Copy link
Author

So, the request to https://slack.com/api/auth.test is failing, even though a token is being supplied, the response back from Slack is:

{
    "ok": false,
    "error": "invalid_auth"
}

Again, weirdly this only fails with accounts except the first account used - am I missing something basic..?

@qdequippe
Copy link

Same error, I tried to online test https://api.slack.com/methods/auth.test/test but I got the same error... I don't understand the Slack documentation...
@roberttolton did you find a way to fix this?

@roberttolton
Copy link
Author

I can't quite remember the exact details, but I ended up putting the users through both flows - 'adding' Slack and then 'login-with' Slack. Bit cumbersome, and I'm sure it's not needed, but was the only thing that worked.

I believe the issue was, whether it's this package at fault or not, that the 'added' flow was done under one account, and then subsequent 'login-with' were different users.

@fritzmg
Copy link

fritzmg commented Dec 30, 2022

Same issue here, though I am only trying a 'standard' workflow via knpuniversity/oauth2-client-bundle. The response from

https://slack.com/api/auth.test?token=…

is also

{
    "ok": false,
    "error": "invalid_auth"
}

May be there is something that needs to be set additionally in the App's settings after all? I have only done the minimum, i.e. only provided the callback URL and added the identity.basic and identity.email scopes and that's it basically.

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

3 participants