!!! OAuth2.0 has been DISABLED !!!
For more information please see the API Key Announcement for more details.
Original post follows
As I mentioned in the Authenticated APIs delayed to week of 2/23 thread we got very close last week to being able to enable to the /v2/account API. Couldn’t quite seal the deal, but the good news is we’ve finished crossing our "t"s and dotting our "i"s on the configuration side of things and everything looks good to go!
So, details. This is considered BETA-quality at the moment and will be more fully fleshed-out later.
/v2/account currently gets you four basic pieces of information.
- The user has a GW2 account
- User’s Account ID (not the game account ID)
- User’s Account Name
- User’s World ID (which you can correlate to /v2/worlds)
Usage is pretty standard OAuth2, the endpoint details are as follows:
- Authorization URL: https://account.guildwars2.com/oauth2/authorization
- Token URL: https://account.guildwars2.com/oauth2/token
Scopes are a space delimited list, currently we only support two:
- account – gives you basic access to the account. It’s required for pretty much any interaction.
- offline – gives you a refresh token in addition to the access token. The refresh token allows you to continue obtaining access tokens after they expire. You’ll probably want this for any non-trivial app.
To access the API you’ll need to turn the code returned by /oauth2/authorization into an access token using /oauth2/token, and then you can use that against /v2/account by passing the following header in your request:
- Authorization: Bearer <access token>
I’ve got a pull request against the api-cdi github repo that provides a small example script written for NodeJS. This is the bare-minimum necessary to make a sucessful request, it is nowhere near production-ready. That should be immediately clear when you see that the directions ask you to copy URL params out of the location bar to pass to another script. I think Lawton’s going to be posting a more complete example in Go shortly.
The UI for managing applications via the account site isn’t ready yet, so we’ve got ahead and created a demo application that you can use for the OAuth2 flow. This application only supports redirects to localhost, so unfortunately you won’t be able to build anything you can ship just yet.
- Key – gw2_api_demo
- Secret – 0357A930-2126-4C87-A006-5AB470298ADA
- Redirects
We’re hoping to get the UI for registering & managing applications ready by next week. Sorry about that, there just wasn’t time to get it to where we’re happy with it and we wanted to get the authenticated API endpoint active sooner rather than later.
(edited by Pat Cavit.9234)