Duplicated avatar when my bot posts PR comment

79 views Asked by At

My bot (a GitHub App) posts a PR comment using the /repos/{owner}/{repo}/issues/{issue_number}/comments endpoint with an installation access token. Strangely, a tiny icon is added to the avatar (see a screenshot).

If I understand correctly, this icon should be added only when authenticating as a user.

Am I doing something wrong? How to get rid of it?

Comment with duplicated avatar

1

There are 1 answers

2
VonC On

Reading "Authenticating with a GitHub App on behalf of a user", you can see the same "tiny icon" on the avatar:

https://docs.github.com/assets/cb-32992/mw-1440/images/help/apps/github-app-acting-on-your-behalf.webp

When an app makes an API request like posting a comment, and it is using a user access token, the GitHub UI will attribute the action to that user, displaying both the user's avatar and the app's identicon badge.

+------------------------------------------------------------+
| GitHub                                                     |
| +-------------------------+   +-------------------------+  |
| | User Avatar             |   | Comment by User         |  |
| | +---------------------+ |   | with App acting         |  |
| | | App Identicon Badge | |   | on behalf               |  |
| | +---------------------+ |   | of User                 |  |
| +-------------------------+   +-------------------------+  |
+------------------------------------------------------------+

Since you are experiencing the addition of the tiny icon (app's identicon badge) to the avatar, it indicates that the bot might be using a user access token (obtained after a user has authorized your app) rather than an installation access token.

If you want the bot's actions to be attributed solely to the app (without showing the user's avatar), you need to use the installation access token. That will show only the app's avatar when the bot posts a comment or takes any action.

If you intend for the actions to be attributed to a user, but without the tiny icon overlapping the avatar, this might not be possible if you are using a user access token since this is how GitHub indicates the action was done via an app on behalf of the user.

But if you are indeed using an installation access token, and you still see an app identicon badge (the tiny icon), then there is no way to get rid of it: that is how GitHub differentiates the action done via an app on behalf of the user, versus an action done by the user.