|
1 | 1 | import base64 |
2 | 2 | from urllib.parse import quote |
3 | | -from .auth import BaseOAuthClient, Scope, TokenProviderInterface |
| 3 | +from .auth import BaseOAuthClient, Scope, TokenProviderInterface, SimpleTokenProvider, OAuthTokenProvider |
4 | 4 |
|
5 | 5 | BASE_URL = 'https://developer.api.autodesk.com/modelderivative/v2' |
6 | 6 | WRITE_SCOPES = [Scope.DataCreate, Scope.DataWrite, Scope.DataRead] |
@@ -38,8 +38,27 @@ def __init__(self, token_provider, base_url=BASE_URL): |
38 | 38 | Create new instance of the client. |
39 | 39 |
|
40 | 40 | Args: |
41 | | - token_provider (TokenProviderInterface): Provider that will be used to generate access tokens for API calls. |
| 41 | + token_provider (autodesk_forge_sdk.auth.TokenProviderInterface): Provider that will be used to generate access tokens for API calls. |
| 42 | +
|
| 43 | + Use `autodesk_forge_sdk.auth.OAuthTokenProvider` if you have your app's client ID and client secret available, |
| 44 | + `autodesk_forge_sdk.auth.SimpleTokenProvider` if you would like to use an existing access token instead, |
| 45 | + or even your own implementation of the `autodesk_forge_sdk.auth.TokenProviderInterface` interface. |
42 | 46 | base_url (str, optional): Base URL for API calls. |
| 47 | +
|
| 48 | + Examples: |
| 49 | + ``` |
| 50 | + FORGE_CLIENT_ID = os.environ["FORGE_CLIENT_ID"] |
| 51 | + FORGE_CLIENT_SECRET = os.environ["FORGE_CLIENT_SECRET"] |
| 52 | + client1 = ModelDerivativeClient(OAuthTokenProvider(FORGE_CLIENT_ID, FORGE_CLIENT_SECRET)) |
| 53 | +
|
| 54 | + FORGE_ACCESS_TOKEN = os.environ["FORGE_ACCESS_TOKEN"] |
| 55 | + client2 = ModelDerivativeClient(SimpleTokenProvider(FORGE_ACCESS_TOKEN)) |
| 56 | +
|
| 57 | + class MyTokenProvider(autodesk_forge_sdk.auth.TokenProviderInterface): |
| 58 | + def get_token(self, scopes): |
| 59 | + return "your own access token retrieved from wherever" |
| 60 | + client3 = ModelDerivativeClient(MyTokenProvider()) |
| 61 | + ``` |
43 | 62 | """ |
44 | 63 | BaseOAuthClient.__init__(self, token_provider, base_url) |
45 | 64 |
|
|
0 commit comments