Get user installations


#1

I’m trying to understand exactly how this URL works:

https://developer.github.com/v3/integrations/#list-installations-for-user

For this purpose, I have created a test account (ID: 27988368) and I already have a test integration (ID: 2179).

Given the following sequence:

  • I’m adding the integration to the test account => it creates Installation A
  • I’m adding the integration to my own account (bdelbasso) => it creates Installation B
  • I’m adding the test account as a collaborator on one of my own repos

Note: I’m able to view the Installations that are created via the integration hooks.

Then requesting the integrations for the test account:

GET /user/installations?access_token=<the oauth token of the test account>

It returns only one installation: installation A.

@keavy Is this the expected behavior?

I would have expected to get installation A and B.


#2

Hi @keavy @jmilas can you tell me if it’s normal that this endpoint does not return the two installations mentioned above?


#3

No, there was a bug in that… you should receive the installations as you originally expected now - any where you AND the Integration have access. Thanks!


#4

Hi @keavy

Thanks for the fix, however it is still broken in my case.

Only installation 24380 (A) is returned, but it should also return installation 24528 (B).


#5

Thanks for the fix, however it is still broken in my case. Only installation 24380 (A) is returned, but it should also return installation 24528 (B).

Thanks for letting us know, @bdelbasso. Could you please provide the full output of a curl -v request which demonstrates the behavior you described? Just make sure you mask the token you used to authenticate in the output of curl -v.


#6

Thanks @izuzak for having a look at this issue.

Here you go:

root@3c458c8cd429:/var/www/devflow# curl -v -H "Authorization: token $TOKEN" -H "Accept: application/vnd.github.machine-man-preview+json" -i "https://api.github.com/user/installations"
*   Trying 192.30.253.117...
* Connected to api.github.com (192.30.253.117) port 443 (#0)
* found 173 certificates in /etc/ssl/certs/ca-certificates.crt
* found 692 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
* 	 server certificate verification OK
* 	 server certificate status verification SKIPPED
* 	 common name: *.github.com (matched)
* 	 server certificate expiration date OK
* 	 server certificate activation date OK
* 	 certificate public key: RSA
* 	 certificate version: #3
* 	 subject: C=US,ST=California,L=San Francisco,O=GitHub\, Inc.,CN=*.github.com
* 	 start date: Wed, 18 Jan 2017 00:00:00 GMT
* 	 expire date: Fri, 17 Apr 2020 12:00:00 GMT
* 	 issuer: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert SHA2 High Assurance Server CA
* 	 compression: NULL
* ALPN, server accepted to use http/1.1
> GET /user/installations HTTP/1.1
> Host: api.github.com
> User-Agent: curl/7.47.0
> Authorization: token *****************
> Accept: application/vnd.github.machine-man-preview+json
> 
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Server: GitHub.com
Server: GitHub.com
< Date: Mon, 29 May 2017 09:26:06 GMT
Date: Mon, 29 May 2017 09:26:06 GMT
< Content-Type: application/json; charset=utf-8
Content-Type: application/json; charset=utf-8
< Content-Length: 3911
Content-Length: 3911
< Status: 200 OK
Status: 200 OK
< X-RateLimit-Limit: 5000
X-RateLimit-Limit: 5000
< X-RateLimit-Remaining: 4992
X-RateLimit-Remaining: 4992
< X-RateLimit-Reset: 1496052685
X-RateLimit-Reset: 1496052685
< Cache-Control: private, max-age=60, s-maxage=60
Cache-Control: private, max-age=60, s-maxage=60
< Vary: Accept, Authorization, Cookie, X-GitHub-OTP
Vary: Accept, Authorization, Cookie, X-GitHub-OTP
< ETag: "4115be165ed460d52fb10f00753cbffc"
ETag: "4115be165ed460d52fb10f00753cbffc"
< X-OAuth-Scopes: 
X-OAuth-Scopes: 
< X-Accepted-OAuth-Scopes: read:user, user
X-Accepted-OAuth-Scopes: read:user, user
< X-OAuth-Client-Id: Iv1.3e22c8b26fc86968
X-OAuth-Client-Id: Iv1.3e22c8b26fc86968
< X-GitHub-Media-Type: github.machine-man-preview; format=json
X-GitHub-Media-Type: github.machine-man-preview; format=json
< Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
< Access-Control-Allow-Origin: *
Access-Control-Allow-Origin: *
< Content-Security-Policy: default-src 'none'
Content-Security-Policy: default-src 'none'
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
< X-Frame-Options: deny
X-Frame-Options: deny
< X-XSS-Protection: 1; mode=block
X-XSS-Protection: 1; mode=block
< Vary: Accept-Encoding
Vary: Accept-Encoding
< X-Served-By: 139317cebd6caf9cd03889139437f00b
X-Served-By: 139317cebd6caf9cd03889139437f00b
< X-GitHub-Request-Id: C617:1FE1:1EA00F4:2626320:592BE92D
X-GitHub-Request-Id: C617:1FE1:1EA00F4:2626320:592BE92D

< 
{
  "total_count": 1,
  "integration_installations": [
    {
      "id": 29070,
      "account": {
        "login": "freelancer4288",
        "id": 27988368,
        "avatar_url": "https://avatars1.githubusercontent.com/u/27988368?v=3",
        "gravatar_id": "",
        "url": "https://api.github.com/users/freelancer4288",
        "html_url": "https://github.com/freelancer4288",
        "followers_url": "https://api.github.com/users/freelancer4288/followers",
        "following_url": "https://api.github.com/users/freelancer4288/following{/other_user}",
        "gists_url": "https://api.github.com/users/freelancer4288/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/freelancer4288/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/freelancer4288/subscriptions",
        "organizations_url": "https://api.github.com/users/freelancer4288/orgs",
        "repos_url": "https://api.github.com/users/freelancer4288/repos",
        "events_url": "https://api.github.com/users/freelancer4288/events{/privacy}",
        "received_events_url": "https://api.github.com/users/freelancer4288/received_events",
        "type": "User",
        "site_admin": false
      },
      "access_tokens_url": "https://api.github.com/installations/29070/access_tokens",
      "repositories_url": "https://api.github.com/installation/repositories",
      "html_url": "https://github.com/settings/installations/29070",
      "integration_id": 2179,
      "app_id": 2179,
      "target_id": 27988368,
      "target_type": "User",
      "permissions": {
        "pull_requests": "write",
        "single_file": "write",
        "contents": "read",
        "metadata": "read"
      },
      "events": [
        "create",
        "delete",
        "pull_request",
        "push"
      ],
      "created_at": "2017-05-29T17:17:42+08:00",
      "updated_at": "2017-05-29T17:17:43+08:00",
      "single_file_name": ".devflow.yml"
    }
  ],
  "installations": [
    {
      "id": 29070,
      "account": {
        "login": "freelancer4288",
        "id": 27988368,
        "avatar_url": "https://avatars1.githubusercontent.com/u/27988368?v=3",
        "gravatar_id": "",
        "url": "https://api.github.com/users/freelancer4288",
        "html_url": "https://github.com/freelancer4288",
        "followers_url": "https://api.github.com/users/freelancer4288/followers",
        "following_url": "https://api.github.com/users/freelancer4288/following{/other_user}",
        "gists_url": "https://api.github.com/users/freelancer4288/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/freelancer4288/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/freelancer4288/subscriptions",
        "organizations_url": "https://api.github.com/users/freelancer4288/orgs",
        "repos_url": "https://api.github.com/users/freelancer4288/repos",
        "events_url": "https://api.github.com/users/freelancer4288/events{/privacy}",
        "received_events_url": "https://api.github.com/users/freelancer4288/received_events",
        "type": "User",
        "site_admin": false
      },
      "access_tokens_url": "https://api.github.com/installations/29070/access_tokens",
      "repositories_url": "https://api.github.com/installation/repositories",
      "html_url": "https://github.com/settings/installations/29070",
      "integration_id": 2179,
      "app_id": 2179,
      "target_id": 27988368,
      "target_type": "User",
      "permissions": {
        "pull_requests": "write",
        "single_file": "write",
        "contents": "read",
        "metadata": "read"
      },
      "events": [
        "create",
        "delete",
        "pull_request",
        "push"
      ],
      "created_at": "2017-05-29T17:17:42+08:00",
      "updated_at": "2017-05-29T17:17:43+08:00",
      "single_file_name": ".devflow.yml"
    }
  ]
}
* Connection #0 to host api.github.com left intact

You can see that only installation 29070 is returned. I’m expecting it to also return installation 24528 because this user (freelancer4288) is an outside collaborator on one repository (php-sample) of organization corresponding to 24528.


#7

You can see that only installation 29070 is returned. I’m expecting it to also return installation 24528 because this user (freelancer4288) is an outside collaborator on one repository (php-sample) of organization corresponding to 24528.

Thanks for that, @bdelbasso. I’ve asked the team to take another look and we’ll followup as soon as we have any news.


#8

@bdelbasso thanks for that info, we’ve made an adjustment to cover that scenario with the installation across the entire account. This endpoint will now return the expected results for you!


#9

Thanks. It works great.