How to retrieve a profile access token?

Not the “basic” access token, I’m talking about the one used for the Account Profile API endpoints. Those require the user to log in to Battle.net, but I’m a bit lost about how I’m supposed to do that as I’m not building a website, but a standalone app with Unity.

You need to get an authorization code first, then you can ask for the access token using that authorization code.

Here’s a fast exemple:

Call the authorization URL

{REGION}.battle. net/oauth/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type={CODE}&scope={SCOPES}

Where

  • {REGION} is the region of the account (us, eu, kr, tw)
  • {CLIENT_ID} is your client id
  • {REDIRECT_URI} is the url you will use to get the authorization code back
  • {CODE} must be “code”
  • {SCOPES} is the scopes you want to use (wow.profile or sc2.profile)

Once the user logs in you will be redirected to your redirect url with the authorization code appended to the end

exemple: myurl. com/oauthtest?code=random_numbers_and_letters

If it’s a mobile application, you need to set that when you go on that url, you are redirected to your app activity

Then you will want to make a POST request to the /oath/token endpoint using that url:
{REGION}.battle. net/oauth/token
You want to use a form data since it’s a POST request with

  • client ID and client secret as authentication
  • from data with
    • {grant_type} = authorization code
    • {redirect_uri} = redirect uri
    • {code} = the authorization code you just got

Once that’s done you should receive a response containing the access_token, token_type, expires_in, scope and refresh_token.

That here is the problem. I’m building a standalone app without a supporting website or whatever, so I don’t know what I’m supposed to put here. A random URL ? Nothing ?

I used a github page for mine, create a new repo, put in a index.html and convert the repo to a page in the settings.

Havn’t had a problem so far and it’s free.

If you are talking about a mobile app you may need to create a custom URL schema: https://www.oauth.com/oauth2-servers/redirect-uris/redirect-uris-native-apps/

Thanks, I’ll see what I can do with that.

Desktop app. Still, that seems like a nice solution, so I’ll definitely have a look.

Could you go into a little more detail on how you made this work for you, please?