Skip to content

Commit

Permalink
feat: ✨ modified user-agent for usage tracking (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
shimizust authored Feb 15, 2023
1 parent f8b3180 commit 5a71b93
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ build/
.pytest_cache/
.env
venv/
.vscode
.vscode
.DS_Store
1 change: 1 addition & 0 deletions linkedin_api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0"
4 changes: 3 additions & 1 deletion linkedin_api/clients/restli/utils/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import linkedin_api.common.constants as constants
from linkedin_api import __version__
from linkedin_api.clients.restli.utils.encoder import encode
from typing import Dict, Any, Optional
from linkedin_api.common.errors import InvalidArgumentError
Expand All @@ -16,7 +17,8 @@ def get_restli_request_headers(*, restli_method: constants.RESTLI_METHODS, acces
"X-RestLi-Protocol-Version": "2.0.0",
"X-RestLi-Method": restli_method.value,
"Authorization": "Bearer " + access_token,
"Content-Type": content_type
"Content-Type": content_type,
"User-Agent": f"linkedin-api-python-client/{__version__}"
}
if (version_string is not None):
headers.update({ "LinkedIn-Version": version_string })
Expand Down
4 changes: 3 additions & 1 deletion tests/clients/restli/client_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from linkedin_api.clients.restli.client import RestliClient
from linkedin_api import __version__
import pytest
import responses
from responses import matchers
Expand Down Expand Up @@ -43,7 +44,8 @@
"Authorization": "Bearer ABC123",
"X-RestLi-Protocol-Version": "2.0.0",
"Content-Type": "application/json",
"X-RestLi-Method": RESTLI_METHODS.GET.value
"X-RestLi-Method": RESTLI_METHODS.GET.value,
"User-Agent": f"linkedin-api-python-client/{__version__}"
},
"response_properties": {
"entity": {"name": "TestAdAccount"}
Expand Down

0 comments on commit 5a71b93

Please sign in to comment.