Invalid OAuth token error

You have already posted the answer:

Step 3 you exchange the ?code for a token.
Then you take the token from the JSON blob and use that in API requests