We are developing a react-native app where the client wants a 'Join Discord' button.
We also want to track if the user has joined our server or not.
So we want:
A Join button which will prompt users to log into/register with discord and join our server. The button will be greyed out if the user has already joined the discord server.
We can create personalized invite links for each user, store links related to each user in db and track the 'uses' of each link to check if the user has joined or not. This is an indirect method, but might work.
We also thought of creating an input field on the react-native app for discord usernames and just checking if that particular user is part of the server already or not.
Both of these implementations seem to be a hassle (for end user or for us)
Is there any better alternative?
Like login using discord and join server?
First of all, you need to make the user login to discord and to your service via discord oauth2. Save user's ID because you need it soon. Then use a bot, add it to your server and check whether that user is in the server or not, and grey the button if he's present. If not, let the bot generate invite link with only one usage, or better yet, make user login with join servers scope, and add user to your server with his auth token.
Related
Very new to the Microsoft ecosystem, trying to understand the flow.
Use-case: we need a Teams bot that sends personal messages to users saying "A customer is waiting at location X" with 2 buttons [Accept] and [Reject] containing personalized links like "https://someurl.com/accept?message=123&user=[user_id]".
How I think I should do it:
Add a special user "servicenotifications#ourdomain.onmicrosoft.com"
Authorize the user & then get a token
Use the token in Send message with cards with cards containing button links
My problem: Got confused with authorizing my special user. Examples on auth V2 require to "redirect the user to the Microsoft identity platform /authorize endpoint." — in a nutshell, show them the login screen, ask for consent and so on.
But my user is a special notification bot, there is no human and I need that fully automated without any user interaction at any point. It's basically a background service sending messages under specific circumstances. Like a Slack bot telling you "Hey, reminder, John has birthday tomorrow".
My questions:
In general, am I moving in the right direction? Or is there a better way for the usecase?
How do I authorize this user without showing any login screen? Because that's an app, a bot, it's not a human and will be controlled fully externally.
Since authentication will be initiated by a bot, the ideal solution is to implement the OAuth2 Client Credentials Flow so that a service principal can be authenticated and authorized. Take a look at Get access without a user for more information.
There may be some operations that may not be allowed for service principals (documented as applications) like Sending chat message to a chat.
I have a simple azure logic app as follows.
Now I add a new action after the first one.
Select an email action.
Look for send email action
Now no mater what I do, I get this error
Please check your account info and/or permissions and try again. Details: REST API is not yet supported for this mailbox. This error can occur for sandbox (test) accounts or for accounts that are on a dedicated (on-premise) mail server. clientRequestId: 9295041e-4d27-4d7f-8ac7-9f90f1cc65ff serviceRequestId: 17c7df3b-7f07-6d27-4f7b-68a4475e9b55 More diagnostic information: x-ms-client-request-id is '51B43F16-6D7C-4BE7-9AE2-7B4A6B73BA49'.
I click Change Connection above and I see these increasing number of connection, and I find no way to delete them. See the last image at the bottom.
And when I click Save, I get this message.
Save logic app failed. Failed to save logic app vivek-logic-app. Some of the connections are not authorized yet. If you just created a workflow from a template, please add the authorized connections to your workflow before saving.
And finally when I click Api Connections, I find no connections to delete.
So two questions.
How to authorize hotmail account te be used by Azure Logic App
How to delete the un-necessary connections
Ok, here it is after a good 3 hour PIA.
For the connections to manage(or delete), look at the resource group and not the Logic app.
And next for the send email action, choose Outlook.Com connection and not Office 365 Outlook. Found the answer here. Mine is personal account and not for work or for school.
Once you setup this action successfully, you can take a look at this page for managing the connection access.
I am trying to access the multiple communities in multiple salesforce sites with same connected-app but could not.
For example: I have created the two salesforce sites A and B. And created connected-app in A. To access rest API of A, i could authenticate with connected-app in A, But how to connect with B with using the same client_secret and client_id by differs in user_name and password?
Or is there any way to connect with REST API with username and password as creds?
Example: There is community_A1, community_A2 in Site A and community_B1 , community_B2 in Site B.
I need to access communities in both the Sites
This should work out of the box, what errors you're getting?
You can have 1 set of consumer key and secret and (if admin in target org didn't block it) you could use this to login to any SF in the world, sandbox or production, core SF or community.
Imagine being a developer of mobile app that pulls data from salesforce. You'd want to have just 1 pair of keys, not install separate key for every org people might install your app...
All org-specific stuff you need is username, password and login url. For community the login url will look like https://sandboxName-MyDomain.cs123.force.com/communityName
Once you have that, you can inspect all the OAuth2 stuff at https://sandboxName-MyDomain.cs123.force.com/communityName/.well-known/openid-configuration
Have you played with https://openidconnect.herokuapp.com/ ?
Paste your community url, for now keep the client and secret as is, click next. Login to community and keep clicking next. It should work fine and at the end - give you access_token / session id.
Now close this browser completely / open new incognito window and do it again. This time give your login url but also client and secret. Next, Next... Check the user's login history, it should mention your connected app now.
Now close this and do it last time, with the other community's login url and another user's credentials but still with your client and secret.
is there any way to connect with REST API with username and password
as creds?
Not for community. Internal users can get access in one go with https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_username_password_flow.htm&type=5 but community/experience users need this interactive login, there has to be a human consent / password typing step. And anyway it's not very secure flow. "Experience Cloud sites don’t support the OAuth 2.0 username-password flow."
In a pinch you could try the SOAP API's login method but from what I remember you may need to pass the community's Id in the message then
Connected-app is global metadata in salesforce. Once we create a connected-app in one org, then can access any salesforce site with the same client_id,client_secret, unless the admin has blocked the access.
I needed to add the custom profile into the community members to allow the access to the community via API (Community workspace -> administration -> members -> profiles.)
I am selling a SaaS product that comes with a Discord server for users. This is a renewal product, so if the user's license expires then I would like to remove them from the server.
How can I achieve this? What input will they need to give me? Is it best to have a login with discord button on my website or should I just have them give me their username then I can send them an invite link when they register, and remove them if their license expires using the API. What if they change their username?
I have done my best to figure out how to achieve both of these approaches by reading https://discordapp.com/developers/docs/intro, but I feel their documentation is seriously lacking and it is difficult to find what I need.
EDIT: It would also be useful to be able to generate one time only invite links. Once the user clicks the link, their discord user ID is sent to me so I can add it into the database. Then, say every day, I scan the database for expired users and if that user has expired then I invoke kick https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.kick. Is this possible?
you get their discord id as soon as they join the discord server by using
client.on('guildmemberadd', (member) {
console.log(member.id)
{```
from there you can hook in your database and simply create a entry containing their
member.id member.username and whatever else you require by a join date Date.now()
I'm using discord.js and I want to create a bot to retreive all the links of a certain channel, but I don't know if it's posible enter to a foreign server with the dicord api, for example join to this server https://discordapp.com/invite/C89qHyt.
Edited:
if it is posible, how I do that?
With a bot account, the client can't enter a server on its own. You have to use OAuth2 to invite the bot to the server. You'll also need the MANAGE_SERVER permission in the server you're trying to add the bot to.
To generate the invite link for your bot, this site may prove very useful.
you can't just add a bot to a group with no invite or permission.
You can't make it join. You have to create a invite link and let the server admin to invite it.