> ## Documentation Index
> Fetch the complete documentation index at: https://stytch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get HubSpot OAuth Access Token

> Retrieve the saved HubSpot access token and ID token for a member

export const oauth = "OAuth, otherwise known as Social Login or Social SSO, is an easy way for end users to sign-up and login to your application through their authenticated identity on another application, such as Google or Microsoft.";

export const member = "Represents an individual end user's account within a given Organization, uniquely identified within that Organization by their email address.";

Retrieve the saved HubSpot access token and ID token for a <Tooltip tip={member}>Member</Tooltip>. After a successful <Tooltip tip={oauth}>OAuth</Tooltip> login, Stytch will save the issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the access token automatically.


## OpenAPI

````yaml GET /v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot
openapi: 3.0.3
info:
  title: Stytch API
  description: The Stytch API provides endpoints for authentication and user management.
  version: 2.1.1
  contact:
    name: Stytch Support
    url: https://stytch.com/docs
    email: support@stytch.com
servers:
  - url: https://api.stytch.com
    description: Production server
  - url: https://test.stytch.com
    description: Test server
security:
  - basicAuth: []
paths:
  /v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot:
    get:
      tags:
        - Members
      summary: Hubspot
      description: >-
        Retrieve the saved Hubspot access token and ID token for a member. After
        a successful OAuth login, Stytch will save the 

        issued access token and ID token from the identity provider. If a
        refresh token has been issued, Stytch will refresh the 

        access token automatically.
      operationId: api_organization_v1_organizations_members_oauth_providers_Hubspot
      parameters:
        - name: organization_id
          in: path
          required: true
          schema:
            type: string
            description: >-
              Globally unique UUID that identifies a specific Organization. The
              `organization_id` is critical to perform operations on an
              Organization, so be sure to preserve this value. You may also use
              the organization_slug or organization_external_id here as a
              convenience.
          description: >-
            Globally unique UUID that identifies a specific Organization. The
            `organization_id` is critical to perform operations on an
            Organization, so be sure to preserve this value. You may also use
            the organization_slug or organization_external_id here as a
            convenience.
        - name: member_id
          in: path
          required: true
          schema:
            type: string
            description: >-
              Globally unique UUID that identifies a specific Member. The
              `member_id` is critical to perform operations on a Member, so be
              sure to preserve this value. You may use an external_id here if
              one is set for the member.
          description: >-
            Globally unique UUID that identifies a specific Member. The
            `member_id` is critical to perform operations on a Member, so be
            sure to preserve this value. You may use an external_id here if one
            is set for the member.
        - name: include_refresh_token
          in: query
          required: false
          schema:
            type: boolean
            description: >-
              Whether to return the refresh token Stytch has stored for the
              OAuth Provider. Defaults to false. **Important:** If your
              application exchanges the refresh token, Stytch may not be able to
              automatically refresh access tokens in the future.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/api_organization_v1_organizations_members_oauth_providers_HubspotResponse
        '400':
          description: Bad request
        '401':
          description: Unauthorized
          content:
            application/json:
              example:
                status_code: 401
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: unauthorized_credentials
                error_message: Unauthorized credentials.
                error_url: https://stytch.com/docs/api/errors/401
        '429':
          description: Too Many Requests
          content:
            application/json:
              example:
                status_code: 429
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: too_many_requests
                error_message: Too many requests have been made.
                error_url: https://stytch.com/docs/api/errors/429
        '500':
          description: Internal server error
          content:
            application/json:
              example:
                status_code: 500
                request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
                error_type: internal_server_error
                error_message: >-
                  Oops, something seems to have gone wrong, please reach out to
                  support@stytch.com to let us know what went wrong.
                error_url: https://stytch.com/docs/api/errors/500
      x-code-samples:
        - lang: csharp
          label: C#
          source: >-
            // GET
            /v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot

            const stytch = require('stytch');


            const client = new stytch.B2BClient({
              project_id: '${projectId}',
              secret: '${secret}',
            });


            const params = {
              organization_id: "organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931",
              member_id: "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
            };


            client.Organizations.Members.OAuthProviders.Hubspot(params)
              .then(resp => { console.log(resp) })
              .catch(err => { console.log(err) });
        - lang: go
          label: Go
          source: "// GET /v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/stytchauth/stytch-go/v18/stytch/b2b/b2bstytchapi\"\n\t\"github.com/stytchauth/stytch-go/v18/stytch/b2b/organizations/members/oauthproviders\"\n)\n\nfunc main() {\n\tclient, err := b2bstytchapi.NewClient(\n\t\t\"${projectId}\",\n\t\t\"${secret}\",\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"error instantiating client: %v\", err)\n\t}\n\n\tparams := &oauthproviders.ProviderInformationParams{\n\t\tOrganizationID: \"organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931\",\n\t\tMemberID:       \"member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f\",\n\t}\n\n\tresp, err := client.Organizations.Members.OAuthProviders.Hubspot(context.Background(), params)\n\tif err != nil {\n\t\tlog.Fatalf(\"error in method call: %v\", err)\n\t}\n\n\tlog.Println(resp)\n}\n"
        - lang: java
          label: Java
          source: >-
            // GET
            /v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot

            package com.example;


            import
            com.stytch.java.b2b.models.organizationsmembersoauthproviders.ProviderInformationRequest;

            import com.stytch.java.b2b.StytchB2BClient;

            import com.stytch.java.common.StytchResult;


            public class Main {
                public static void main(String[] args) {
                    StytchB2BClient.configure("${projectId}", "${secret}");

                    ProviderInformationRequest params = new ProviderInformationRequest();
                    params.setOrganizationId("organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931");
                    params.setMemberId("member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f");

                    Object result = StytchB2BClient.getOrganizations().getMembers().getOAuthProviders().hubspot(params);
                    if (result instanceof StytchResult.Success) {
                      System.out.println(((StytchResult.Success) result).getValue());
                    } else {
                      System.out.println(((StytchResult.Error) result).getException());
                    }
                }
            }
        - lang: kotlin
          label: Kotlin
          source: >
            // GET
            /v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot

            package com.example


            import com.stytch.java.b2b.StytchB2BClient

            import
            com.stytch.java.b2b.models.organizationsmembersoauthproviders.ProviderInformationRequest


            fun main() {
                StytchB2BClient.configure(
                    projectId = "${projectId}",
                    secret = "${secret}",
                )

                when (
                    val result =
                        StytchB2BClient.organizations.members.oauthProviders.hubspot(
                            ProviderInformationRequest(
                                organizationId = "organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931",
                                memberId = "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
                            ),
                        )
                ) {
                    is StytchResult.Success -> println(result.value)
                    is StytchResult.Error -> println(result.exception)
                }
            }
        - lang: javascript
          label: Node.js
          source: >-
            // GET
            /v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot

            const stytch = require('stytch');


            const client = new stytch.B2BClient({
              project_id: '${projectId}',
              secret: '${secret}',
            });


            const params = {
              organization_id: "organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931",
              member_id: "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
            };


            client.organizations.members.oauthProviders.hubspot(params)
              .then(resp => { console.log(resp) })
              .catch(err => { console.log(err) });
        - lang: php
          label: PHP
          source: >-
            $response =
            $client->organizations->members->oauth_providers->hubspot([
                'organization_id' => 'organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931',
                'member_id' => 'member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f',
            ]);
        - lang: python
          label: Python
          source: >
            # GET
            /v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot

            from stytch import B2BClient


            client = B2BClient(
                project_id="${projectId}",
                secret="${secret}",
            )


            resp = client.organizations.members.oauth_providers.hubspot(
                organization_id="organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931",
                member_id="member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
            )


            print(resp)
        - lang: ruby
          label: Ruby
          source: >-
            # frozen_string_literal: true


            # GET
            /v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot

            require 'stytch'


            client = StytchB2B::Client.new(
              project_id: "${projectId}",
              secret: "${secret}"
            )


            resp = client.organizations.members.oauth_providers.hubspot(
              organization_id: "organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931",
              member_id: "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f"
              
            )


            puts resp
        - lang: rust
          label: Rust
          source: >-
            // GET
            /v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot

            use stytch::b2b::client::Client;

            use
            stytch::b2b::organizations_members_oauth_providers::ProviderInformationRequest;


            fn main() {
                let client = Client::new("${projectId}", "${secret}").unwrap();
                let resp = client.organizations.members.oauth_providers.hubspot(
                    ProviderInformationRequest{
                        organization_id: "organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931",
                        member_id: "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
                        ..Default::default()
                    }
                ).await;
                println!("The response is {:?}", resp);
            }
        - lang: bash
          label: cURL
          source: >-
            # GET
            /v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot

            curl --request GET \
              --url https://test.stytch.com/v1/b2b/organizations/organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931/members/member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f/oauth_providers/hubspot \
              -u '${projectId}:${secret}' \
              -H 'Content-Type: application/json'
components:
  schemas:
    api_organization_v1_organizations_members_oauth_providers_HubspotResponse:
      type: object
      properties:
        request_id:
          type: string
          description: >-
            Globally unique UUID that is returned with every API call. This
            value is important to log for debugging purposes; we may ask for
            this value to help identify a specific API call when helping you
            debug an issue.
        provider_type:
          type: string
          description: >-
            Denotes the OAuth identity provider that the user has authenticated
            with, e.g. Google, Microsoft, GitHub etc.
        registrations:
          type: array
          items:
            $ref: '#/components/schemas/api_organization_v1_HubspotProviderInfo'
          description: A list of tokens the member is registered with.
        status_code:
          type: integer
          format: int32
          description: >-
            The HTTP status code of the response. Stytch follows standard HTTP
            response status code patterns, e.g. 2XX values equate to success,
            3XX values are redirects, 4XX are client errors, and 5XX are server
            errors.
      required:
        - request_id
        - provider_type
        - registrations
        - status_code
    api_organization_v1_HubspotProviderInfo:
      type: object
      properties:
        provider_subject:
          type: string
          description: >-
            The unique identifier for the User within a given OAuth provider.
            Also commonly called the `sub` or "Subject field" in OAuth
            protocols.
        provider_tenant_id:
          type: string
          description: >-
            The tenant ID returned by the OAuth provider. This is typically used
            to identify an organization or group within the provider's domain.
            For example, in HubSpot this is a Hub ID, in Slack this is the
            Workspace ID, and in GitHub this is an organization ID. This field
            will only be populated if exactly one tenant ID is returned from a
            successful OAuth authentication and developers should prefer
            `provider_tenant_ids` over this since it accounts for the
            possibility of an OAuth provider yielding multiple tenant IDs.
        access_token:
          type: string
          description: >-
            The `access_token` that you may use to access the User's data in the
            provider's API.
        access_token_expires_in:
          type: integer
          format: int32
          description: The number of seconds until the access token expires.
        scopes:
          type: array
          items:
            type: string
          description: >-
            The OAuth scopes included for a given provider. See each provider's
            section above to see which scopes are included by default and how to
            add custom scopes.
        refresh_token:
          type: string
          description: >-
            The `refresh_token` that you may use to obtain a new `access_token`
            for the User within the provider's API.
      required:
        - provider_subject
        - provider_tenant_id
        - access_token
        - access_token_expires_in
        - scopes
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

````