title: How to find user's patreon pledge tier using django-allauth for authentication
body: <p>I’m using django-allauth to authenticate users (uses <a href="https://docs.patreon.com/#introduction" rel="noreferrer">Patreon's API v1</a>), which adds a json to the database with the info below. I would like to show extra content on the site if the user's pledge matches a particular tier (or is above one).</p>
  
  <pre><code>{
    "attributes": {
      "about": null,
      "can_see_nsfw": true,
      "created": "2019-05-20T20:29:02.000+00:00",
      "default_country_code": null,
      "discord_id": null,
      "email": "admin@email.com",
      "facebook": null,
      "facebook_id": null,
      "first_name": "Adm",
      "full_name": "Adm Nsm",
      "gender": 0,
      "has_password": true,
      "image_url": "https://c8.patreon.com/2/200/21383296",
      "is_deleted": false,
      "is_email_verified": false,
      "is_nuked": false,
      "is_suspended": false,
      "last_name": "Nsm",
      "social_connections": {
        "deviantart": null,
        "discord": null,
        "facebook": null,
        "instagram": null,
        "reddit": null,
        "spotify": null,
        "twitch": null,
        "twitter": null,
        "youtube": null
      },
      "thumb_url": "https://c8.patreon.com/2/200/21383296",
      "twitch": null,
      "twitter": null,
      "url": "https://www.patreon.com/user?u=21383296",
      "vanity": null,
      "youtube": null
    },
    "id": "21383296",
    "relationships": {
      "pledges": {
        "data": [
          {
            "id": "24461189",
            "type": "pledge"
          }
        ]
      }
    },
    "type": "user"
  }
  </code></pre>
  
  <p>At first I though relationships.pledges.data.id would have the ID of the current tier and with that I managed to add an extra block of content for a specific user, but apparently that was only wishful thinking; after testing with a second account the ID that I though was the pledge level seems to differ each time. I imagine I might need to request more info from <a href="https://docs.patreon.com/#introduction" rel="noreferrer">Patreon's API</a>, but am unsure how to get what I need back.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>From what I can gather, I would need to request the <strong>currently_entitled_tiers</strong> from <strong>/api/oauth2/v2/members/{id}</strong></p>
  
  <p>The problem is that the ID required there is not the same ID I get after a user logs in. So I would first need to use the oauth access token that's been generated and GET <strong>/api/oauth2/v2/identity</strong> for the long ID number.</p>
  
  <p>My current problem is that when I try to get the ID from /api/oauth2/v2/identity I receive a 401 error code:</p>
  
  <pre><code>&lt;Response [401]&gt;
  {'errors': [{'code': 1, 'code_name': 'Unauthorized', 'detail': "The server could not verify that you are authorized to access the URL requested.  You either supplied the wrong credentia
  ls (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.", 'id': 'b298d8b1-73db-46ab-b3f4-545e6f934599', 'status': '401', 'title': 'Unauthori
  zed'}]}
  </code></pre>
  
  <p>What I'm sending is:</p>
  
  <pre class="lang-py prettyprint-override"><code>headers = {"authorization": "Bearer " + str(access_token)}  # User's Access Token
  req = requests.get("https://patreon.com/api/oauth2/v2/identity?include=memberships", headers=headers)
  </code></pre>
  
  <p>If I get the proper ID through <strong>/api/oauth2/v2/campaigns/{campaign_id}/members</strong> I can request from <strong>/api/oauth2/v2/members/{id}</strong> and get what I need, but that middle step using the currently logged in user to get their ID eludes me.</p>
  
  <p>Thank you.</p>