Bungie-net / api

Resources for the Bungie.net API
Other
1.22k stars 92 forks source link

Request on protected resources #832

Open hugovanier opened 5 years ago

hugovanier commented 5 years ago

Hi I don’t understand how to make a request on a protected resources. I have my token, but how to use like « ReadDestinyInventoryAndVault », it’s a mystery to me. Could you give me a example please?!!

vthornheart-bng commented 5 years ago

Hi! Just to make sure I understand the question - you have implemented OAuth and gotten a token for - say - your own user account, and now you want to pull your non-equipped inventory and vault information?

Just to make sure the preliminaries are set: when you added your application, did you check the box that said "Read your Destiny vault and character inventory."? You'll need that checked off in order to get at this information to start with.

Let me know if I have understood your question correctly, and if that permission checkbox is indeed checked off, and we can go from there!

hugovanier commented 5 years ago

Hi vthornheart (BTW, sorry for my English skills, l’m a french canadien.) First, thanks for your support. Exactly, I want to pull my non-equipped inventory and vault information.

I confirm to you that the checkbox for the application "scope” is already checked. So, yes I use my own account. Voilà My question is perhaps dummy, but I’m a Power BI and T-SQL guy and nothing else haha.

vthornheart-bng commented 5 years ago

Awesome, and welcome!

Excellent, so now that you've got OAuth working, what you'll need to do is call the appropriate endpoint and pass the right "components".

The best one to call would be GetProfile:

https://bungie-net.github.io/multi/operation_get_Destiny2-GetProfile.html#operation_get_Destiny2-GetProfile

Take a look at the components on the response object, where it says "Depends on Component ____":

https://bungie-net.github.io/multi/schema_Destiny-Responses-DestinyProfileResponse.html#schema_Destiny-Responses-DestinyProfileResponse

You have to pass those components in the querystring parameters of the request in order to receive that data. It's not intuitive unfortunately, and I should add better documentation for it, but the Vault is actually a "profile-level" inventory bucket. So that means what you're looking for is the "ProfileInventories" and "CharacterInventories" components.

If that summary information is what you want, you'd make your request as such:

https://www.bungie.net/Platform/Destiny2/{MEMBERSHIP TYPE}/Profile/{MEMBERSHIP ID}/?components=ProfileInventories,CharacterInventories

If you want more detailed information, like the info about sockets on all the items, you'd want to look into passing "Item" components. You can see the full list of components you can request here:

https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html#schema_Destiny-DestinyComponentType

The last thing you'll want to do - which you may have already done - is grab the Manifest Databases so that you can get static data about the items such as their localized strings, icons, etc... as the data passed from the "live" endpoints is only "mutable" data. Any data that is fixed is something we return in said databases, and you use the various "hash" properties you'll find in the results you get to lookup the definition and find that static data.

Give that a shot, and let me know if that helps!

hugovanier commented 5 years ago

Ok, thanks a lot for these details. I was already on the right way. I think my problem is how i use my authorization header, as the unprotected resources are ok. I add 2 images. The first (CharacterEquipment) tells me that the json file is complete. The second (ProfileInventories) tells me that the "part data" is absent. 2019-01-08 12_48_06-bungie - editeur power query 2019-01-08 12_48_48-bungie - editeur power query

vthornheart-bng commented 5 years ago

Oh, I see!

Yes, hit this up for more information, this should hopefully be helpful:

https://github.com/Bungie-net/api/wiki/OAuth-Documentation