Installing an App on an Organization

community-help

#1

Hey there,

I am developing an app with the GitHub API and I was wondering how I can differentiate who installed the app. Is there a way to determine if the generated token is from an organization install, or an actual user?

Thanks!


#2

:wave: @james-stewart2,

Sorry for the delay here. I’ve moved this question over to the GitHub Apps section of the site to better assist you.


#3

Sure is - use this endpoint and check the target_type or the type of the account.

@bswinnerton - the docs for that endpoint are wrong, if you fancy updating them The full response last time I checked was:

{
    "access_tokens_url": "https://api.github.com/installations/25222/access_tokens",
    "account": {
        "avatar_url": "https://avatars3.githubusercontent.com/u/1144873?v=3",
        "events_url": "https://api.github.com/users/greysteil/events{/privacy}",
        "followers_url": "https://api.github.com/users/greysteil/followers",
        "following_url": "https://api.github.com/users/greysteil/following{/other_user}",
        "gists_url": "https://api.github.com/users/greysteil/gists{/gist_id}",
        "gravatar_id": "",
        "html_url": "https://github.com/greysteil",
        "id": 1144873,
        "login": "greysteil",
        "organizations_url": "https://api.github.com/users/greysteil/orgs",
        "received_events_url": "https://api.github.com/users/greysteil/received_events",
        "repos_url": "https://api.github.com/users/greysteil/repos",
        "site_admin": false,
        "starred_url": "https://api.github.com/users/greysteil/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/greysteil/subscriptions",
        "type": "User",
        "url": "https://api.github.com/users/greysteil"
    },
    "app_id": 2141,
    "created_at": "2017-05-15T20:17:13.000Z",
    "events": [
        "delete",
        "issues",
        "issue_comment",
        "pull_request",
        "push",
        "repository",
        "status"
    ],
    "html_url": "https://github.com/settings/installations/25222",
    "id": 25222,
    "integration_id": 2141,
    "permissions": {
        "contents": "write",
        "issues": "write",
        "metadata": "read",
        "pull_requests": "write",
        "statuses": "read"
    },
    "repositories_url": "https://api.github.com/installation/repositories",
    "repository_selection": "selected",
    "single_file_name": null,
    "target_id": 1144873,
    "target_type": "User",
    "updated_at": "2017-05-15T20:17:13.000Z"
}