How do you create a redirect URI? - discord

So, a redirect URI is required to invite your Discord bot to your server. However, I tried using this as my redirect URI (replacing CLIENTID with my bot's client ID) and it didn't work:
https://discordapp.com/oauth2/authorize?&client_id=%5BCLIENTID%5D&scope=bot
It says "CLIENT ID is not a snowflake" after trying to invite my bot. How do I fix this, as I've looked everywhere with no good solutions.

Related

Use Discord's API to send message as user

I want to send a message in a Discord channel but from a user account not a bot. Is this kind of thing possible using Discord's API?
The official documentation should contain enough information to get started: https://discord.com/developers/docs/resources/channel#create-message
Make sure to login with OAuth2 and not as a bot. Also, it is important to get the right scope (permissions) when requesting an OAuth token.

How to change server vanity url with discord.js

As it says in the title, how can I change it with discord.js? I want to change using api v8 or using discord bot.
Unfortunately, because only guilds with level 3 can set a vanity URL, you can only set a vanity URL through the official Discord app. However you can recieve a guilds vanity URL with the following link: https://discord.com/api/v8/guilds/{guild-id}/vanity-url. Assuming your bot has MANAGE_GUILD permissions and you define the Authorization header.

Is it possible to find out what discord bot a token belongs to?

I got multiple discord bots and sometimes it would be useful to find out to what bot a token belongs to via the API or some other way?
I'm using Javachord and I've found there's a getYourself() in DiscordApi that returns a User which represents the current bot.
I'm not sure how that maps to the Discord API itself though
Here's an alternative solution.
Discord has an API endpoint users/#me that returns the current user's user object.
Try this for an example:
curl -H "Authorization: Bot <token>" https://discord.com/api/v9/users/#me
Discord also sends back a user object (part of lots more info) as part of the Identify process when using its websocket gateways, but this probably isn't what you would want.

discord bot missing permission but granted admin access

I'm trying to hit the /guilds/{guildId} endpoint, and I've created a bot and installed it on the server I'm trying to access and even granted it admin access, but I'm still getting a "missing access" error:
In this case, Error 403 either means that the Bot is not in a guild with that id or that there is no guild with the id you provided in the URL.
Make sure, you copied the id of the correct server.
Double check if you are using the correct token and if you're posting to the right guild.
If the bot has administrator, it simply has access to all channels. This error means that the bot user either does not have permission or is not in that guild.

Keycloak delete user give me an 401 Unauthorized error

I am trying to delete a user from a realm using keycloak admin client api.
I am following an example from here:
https://gist.github.com/thomasdarimont/43689aefb37540624e35
Here is what my code looks like:
Keycloak kc = KeycloakBuilder.builder().serverUrl("https://localhost:8445/auth")
.realm("sensorcloud-auth").username("admin").password("admin").clientId("admin-cli")
.clientSecret("b6b4f0ec-9936-46a2-9f40-69c207e2e0f2")
.resteasyClient(new ResteasyClientBuilder().connectionPoolSize(10).build()).build();
kc.realm("sensorcloud-auth").users().get("a3fdac49-f7eb-4be7-a81f-b48b09a6694c").remove();
I can login to keycloak admin console using username admin and password admin, and I am pretty sure there is no typo with other parameters, but every time when I try to delete the user with that userId, I will be given a 401 Unauthorized error. Can someone help me figure out what is going on?
Not sure which version of keycloak admin client api you are using, with current API there is no remove operation.
It should be kc.realm(realmName).users().delete(id) . You can check the REST API for Delete User
We kept getting HTTP 401 status code responses when the hostname stamped on the iss field of the bearer's/user's access token had a different case i.e. lowercase vs. uppercase than the url used to post an HTTP request to keycloak's token endpoint.
While creating Keycloak instance, Realm should be master realm.
After creating instance with Master Realm, you can delete the user by using your code.

Resources