Cannot use Chat API


#1

I always get the “You are not authorized to perform this action.” error.

My steps:
1- Create an app
2- generate both clientside and serversize APIKey
3- Go to Chat API documentation and authorize with clientside Key
4- Fill the form with the ID of the hub and a message
5 - Send, then fail
6- Authozize with a serverside key and do the same thing.
7- Also fail

Thankyou for the help, please let me know if I’m doing something wrong


#2

Same problem, API and WebHooks not working. :neutral_face:


#3

Hi lugui98,
you’re doing it wrong…now I can explain you why.
Basically you’re calling the Chat-api with an APIkey as authentication, which is mean to be used for services like Data-api, where the behaviour (the contenf of the responses) is independent from the caller.

For the Chat-api you need to use an access_token, which is a token that is gained trough an OAuth flow, where a user log-in and explicitly approve your app to write inside chatrooms using his account. These token are often called “on behalf of the user”.
So here are the steps to make it working:

  • Create an OAuth2 Clients Id from the developer portal (not an API key) with the scopes you need for your project (e.g. you can ask permissions for only reading chat, not writing and so on). Remember that the users will be prompted to approve these permissions, so usually…more you ask, less users will approve your app :wink:
  • Implement an Oauth flow (implicit flow or authorization code flow) following our guides
  • When is working, users will be prompted to login into FACEIT and approve you app using the consent screen
  • If a user approve, an access_token will be returned to the redirect_uri you specified on the developer portal. This token is “on behalf of the user”, so you can use it for writing inside chatrooms in the name of the user.

Cheers!
Lorenzo


#4

Hello Lorenzo; Thankyou for the reply.

I’m not sure if it is a problem on the Faceit API (probably not). What is the authorization URL?
I’m using this: https://api.faceit.com/auth/v1/api/authorize?client_id=SOME_ID_HERE
Whatever ID I use I get the following error: “Access is deniedaccess_denied”
I’ve tryed the OAuth client Id and Secret, APikey both server and client side, and event the appid.
Am I using the right URL? If yes, What ID am I supoded to use?

Thankyou for the help


#5

Hi lugui98,
you have to integrate the FACEIT Connect in your project, to make it working easily.
You can read the documentation here as is well explained.
If you have other questions regarding the FACEIT Connect, or if you’re looking for an help, you can use the FACEIT Connect category of this forum.

Cheers
Lorenzo


#6