Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make discovery match the Tent spec #15

Closed
longears opened this issue Sep 29, 2012 · 3 comments
Closed

Make discovery match the Tent spec #15

longears opened this issue Sep 29, 2012 · 3 comments
Assignees
Labels

Comments

@longears
Copy link
Owner

The code works right now on tent.is but it's not exactly following the Tent spec.

The proper thing to do is:

  • First of all, all of these requests need to use this header:
Accept: application/vnd.tent.v0+json
  • Start with the entity URL, https://longears.tent.is
  • Do a HEAD request to get the HTTP Link headers which will point to the profile API address: https://longears.tent.is/tent/profile. If there are no Link headers, do a GET request and look in the HTML body for <link> tags. These URLs can be relative or absolute.
  • Use the profile API URLs to get the profile by doing a GET request. This is the GET /profile API method.
  • In the returned JSON, look up json['https://tent.io/types/info/core/v0.1.0']['servers'] which will be a list of API endpoints. In the case of tent.is, there will be only one and it will be https://longears.tent.is/tent unless the user changed it by updating their profile using the API
  • Also in the returned JSON, look up json['https://tent.io/types/info/core/v0.1.0']['entity'] and use that as the entity URL from now on. It might be different than the one you started with.

Notes on Link headers: python's requests library only gives us the last one when more than one is specified. We can fix that by parsing the Link header ourselves by grabbing it from r.headers['Link'] and splitting it into separate items. This would happen in TentApp.discoverAPIUrls().

See https://tent.io/types/info/core/v0.1.0 for details of the HTTP Link header
See https://tent.io/docs/app-server for an example JSON response to a GET /profile
See tent/tent.io#72 for more discussion about this

Also, detection of tags in the HTML works but is not robust. We should use an HTML-parsing library to find the tags.

@longears
Copy link
Owner Author

longears commented Oct 3, 2012

working on this now...

@longears
Copy link
Owner Author

longears commented Oct 3, 2012

Done! Needs testing on a server that uses relative URLs in its Link header.

@longears longears closed this as completed Oct 3, 2012
@followben
Copy link

Thanks for this David - your description helped enormously with followben/TPTentClient@082139c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants