|
56 | 56 | "metadata": {}, |
57 | 57 | "outputs": [], |
58 | 58 | "source": [ |
59 | | - "from evo.oauth import AuthorizationCodeAuthorizer, OAuthScopes\n", |
| 59 | + "from evo.oauth import AuthorizationCodeAuthorizer, EvoScopes\n", |
60 | 60 | "\n", |
61 | 61 | "authorizer = AuthorizationCodeAuthorizer(\n", |
62 | 62 | " oauth_connector=connector,\n", |
63 | 63 | " redirect_url=REDIRECT_URL,\n", |
64 | | - " scopes=OAuthScopes.all_evo | OAuthScopes.offline_access,\n", |
| 64 | + " scopes=EvoScopes.all_evo | EvoScopes.offline_access,\n", |
65 | 65 | ")\n", |
66 | 66 | "await authorizer.login()\n", |
67 | 67 | "print(await authorizer.get_default_headers())" |
|
105 | 105 | "metadata": {}, |
106 | 106 | "outputs": [], |
107 | 107 | "source": [ |
108 | | - "from evo.oauth import OAuthRedirectHandler, OAuthScopes\n", |
| 108 | + "from evo.oauth import EvoScopes, OAuthRedirectHandler\n", |
109 | 109 | "\n", |
110 | 110 | "async with OAuthRedirectHandler(connector, REDIRECT_URL) as handler:\n", |
111 | | - " result = await handler.login(OAuthScopes.all_evo | OAuthScopes.offline_access)\n", |
| 111 | + " result = await handler.login(EvoScopes.all_evo | EvoScopes.offline_access)\n", |
112 | 112 | "\n", |
113 | 113 | "print(f\"Access token: {result.access_token}\")" |
114 | 114 | ] |
|
129 | 129 | "outputs": [], |
130 | 130 | "source": [ |
131 | 131 | "from evo.aio import AioTransport\n", |
132 | | - "from evo.oauth import ClientCredentialsAuthorizer, OAuthConnector, OAuthScopes\n", |
| 132 | + "from evo.oauth import ClientCredentialsAuthorizer, EvoScopes, OAuthConnector\n", |
133 | 133 | "\n", |
134 | 134 | "# OAuth client app credentials\n", |
135 | 135 | "# See: https://developer.seequent.com/docs/guides/getting-started/apps-and-tokens\n", |
|
143 | 143 | " client_id=CLIENT_ID,\n", |
144 | 144 | " client_secret=CLIENT_SECRET,\n", |
145 | 145 | " ),\n", |
146 | | - " scopes=OAuthScopes.evo_discovery | OAuthScopes.evo_workspace,\n", |
| 146 | + " scopes=EvoScopes.evo_discovery | EvoScopes.evo_workspace,\n", |
147 | 147 | ")\n", |
148 | 148 | "\n", |
149 | 149 | "print(await authorizer.get_default_headers())" |
150 | 150 | ] |
| 151 | + }, |
| 152 | + { |
| 153 | + "cell_type": "markdown", |
| 154 | + "metadata": {}, |
| 155 | + "source": [ |
| 156 | + "## Custom OAuth Scopes\n", |
| 157 | + "\n", |
| 158 | + "The `Scopes` type makes it easy to request custom OAuth scopes. You can combine predefined scope groups with custom scopes using the bitwise OR operator (`|`)." |
| 159 | + ] |
| 160 | + }, |
| 161 | + { |
| 162 | + "cell_type": "code", |
| 163 | + "execution_count": null, |
| 164 | + "metadata": {}, |
| 165 | + "outputs": [], |
| 166 | + "source": [ |
| 167 | + "from evo.oauth import EvoScopes, Scopes\n", |
| 168 | + "\n", |
| 169 | + "print(EvoScopes.default) # Predefined default scopes\n", |
| 170 | + "\n", |
| 171 | + "# Predefined scopes can be combined with Scopes instances:\n", |
| 172 | + "print(EvoScopes.default | Scopes(\"custom-scope1 custom-scope2\"))\n", |
| 173 | + "\n", |
| 174 | + "# Predefined scopes can be combined with str instances:\n", |
| 175 | + "print(EvoScopes.default | \"custom-scope1 custom-scope2\")\n", |
| 176 | + "\n", |
| 177 | + "# Scopes instances can be combined with str instances:\n", |
| 178 | + "print(Scopes(\"custom-scope1\") | \"custom-scope2\")\n", |
| 179 | + "\n", |
| 180 | + "# Combining scopes is commutative:\n", |
| 181 | + "print(EvoScopes.default | \"custom-scope1 custom-scope2\")\n", |
| 182 | + "print(\"custom-scope1 custom-scope2\" | EvoScopes.default)" |
| 183 | + ] |
151 | 184 | } |
152 | 185 | ], |
153 | 186 | "metadata": { |
154 | 187 | "kernelspec": { |
155 | | - "display_name": "venv", |
| 188 | + "display_name": "evo-sdk", |
156 | 189 | "language": "python", |
157 | 190 | "name": "python3" |
158 | 191 | }, |
|
0 commit comments