Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
SDKs
Python SDK
Commits
9ba34d19
Commit
9ba34d19
authored
Jun 25, 2020
by
Daniel Scholl
Browse files
Merge branch 'weisun/feature/azure_provider' into 'master'
add entitlements client for azure provider See merge request
!1
parents
98e845cd
3a2b348e
Changes
2
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
9ba34d19
...
...
@@ -4,4 +4,5 @@ osdu_api.egg-info
__pycache__
**/venv/**
**/.idea/**
\ No newline at end of file
**/.idea/**
.vscode/
\ No newline at end of file
osdu_api/provider/azure/entitlements_client.py
0 → 100644
View file @
9ba34d19
# Copyright © Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
import
importlib
import
importlib.util
from
urllib.request
import
Request
,
urlopen
from
urllib.parse
import
urlencode
from
urllib.error
import
HTTPError
from
json
import
loads
def
get_bearer_token
():
client_id
=
os
.
environ
[
'client_id'
]
client_secret
=
os
.
environ
[
'client_secret'
]
tenant_id
=
os
.
environ
[
'tenant_id'
]
token_endpoint
=
os
.
environ
[
'token_endpoint'
]
resource
=
os
.
environ
[
'resource'
]
body
=
{
"grant_type"
:
"client_credentials"
,
"client_id"
:
client_id
,
"client_secret"
:
client_secret
,
"resource"
:
resource
}
headers
=
{
"Content-Type"
:
"application/x-www-form-urlencoded"
}
data
=
urlencode
(
body
).
encode
(
"utf8"
)
request
=
Request
(
url
=
token_endpoint
,
data
=
data
,
headers
=
headers
)
try
:
response
=
urlopen
(
request
)
response_body
=
response
.
read
()
resp
=
loads
(
response_body
)
token
=
resp
[
"access_token"
]
except
HTTPError
:
raise
return
f
'Bearer
{
token
}
'
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment