Hi there, Do you have a recipe for login with Slack? I am using Flutter frontend and python(FastAPI...
y
Hi there, Do you have a recipe for login with Slack? I am using Flutter frontend and python(FastAPI) backend.
r
Hey @yogeshksoni slack is not an inbuilt provider we have. Please refer to our custom provider method
y
I wonder if supertokens can be used only for auth or can we use it for requestion additional scopes post signin?
r
you can use it for both
y
I can't find the dart frontend code when using custom providers. Can you please share the link?
y
thank you
Hi - When we create a custom provider, is there a redirect url by default? Just like for built in Google login provider, we have /auth/callback/google? - What should the custom callback URL do such that supertokens creates the user session?
r
- yes, it would be /auth/callback/slack (assuming the thirdpartyid you have given is slack)
If you are using our pre built ui, you don’t need to do anything in the callback as our SDK will handle it
(On that specific route)
y
I am creating custom UI using flutter (mac desktop app)
r
Right. So you need to handle the callback in the same way that you are handling for google
y
I am not doing much to handle google callback. Google returns the authcode to redirect ui, which is my flutter app. Then I call supertokens signinup post api. I am not sure when exactly /auth/callback/google is being called actually. Unfortunately Slack won't allow me to redirect the auth codes and token directly to my app. They require the redirect URL to be an https link (which is where /auth/slack/callback) comes in. Where can I see the implementation of /auth/slack/callback? What exactly does it do? does it use access_token and id_token to create the user session?
r
So you need to basically get the tokens provided by slack and call the signinup api from your frontend app.
Now how you get those tokens is up to you.
y
ok. Then I am back to the same question. If frontend has to call signinup api with token , when exactly is /auth/slack/callback called and why?
r
That’s not called. I’m not sure what you are referring to
For custom ui, you can set the callback to anything you like.
The aim is to just get the tokens on the frontend and call that signinup api
y
Got it. Thanks. I will have to find a work around. Since Slack mandates me to use an https link for redirect uri, I may have to create an https deep link in my mac app, which can serve as redirect URI. Phew.
r
Yea, or, you could make an api in your backend which slack calls, and the api then redirects to the deep link of your app
y
yeah, that could work too. I have to be careful as the access tokens are being exchanged.
r
You don't really need to exchange the access token in this step. That happens when u call signinup API. Here you only need to do a redirection from your api (which is https) to your app (which is non https).
y
hmm the way I understand the flow is this 1. user -> signin with slack using slack auth api 2. slack auth server -> return the auth code to redirect_uri. In my future scenario 3. slack auth server -> give code to backend redirect uri 4. backend call deep link (with auth code) -> app gets the auth code 5. app calls supertoken signinup api with code -> supertokens creates session So does the redirection in step 3 not involve exchange of code?
r
it doesn't invlove code exchange. Code exchange happens when you call the signinup API. Our sdk does it
so your api is literally just a redirection api
y
Here is a code block from your documentation for google sign in, (i have implemented it and it is working). The redirection with auth code happens at googleSignIn.signIn() call and the mac app receives auth code. Supertoken is not involved at this stage at all. This is where I am struggling with Slack. GoogleSignInAccount? account = await googleSignIn.signIn(); if (account == null) { print("Google sign in was aborted"); return; } String? authCode = account.serverAuthCode; if (authCode == null) { print("Google sign in did not return a server auth code"); return; } // Refer to step 2 }
r
ah yea. Thats cause the google lib does that.
Now if slack gives you the auth code, you give that to the signinup API
y
Yeah. I am sure, it will be straight forward after that (hopefully). But I can't get the code from slack because they don't allow redirection to my app directly 😦 . Anyways, I will try to create deep links and see if it helps. Once I receive the code, I will try calling supertokens signinup api
r
cool!
y
Thanks
So, I managed to obtain access_token and id_token from Slack. Now I called Supertokens signinup api and passed these values in a custom provider. I get the following error: Does it ring any bells? I get no such error when logging in with Google using the exact same method. env/lib/python3.11/site-packages/jwt/api_jws.py", line 310, in _verify_signature raise InvalidSignatureError("Signature verification failed") jwt.exceptions.InvalidSignatureError: Signature verification failed
Never mind. It was an error on my side. I fixed it. Now signinup API returns me valid json response.
11 Views