Skip to content

Commit

Permalink
Merge pull request #21 from intuit/401k
Browse files Browse the repository at this point in the history
401K_Support
  • Loading branch information
abisalehalliprasan authored Aug 11, 2020
2 parents 85191fd + f5c49f6 commit 6a40386
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
12 changes: 12 additions & 0 deletions intuitlib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ def __init__(self, client_id, client_secret, redirect_uri, environment, state_to
self.x_refresh_token_expires_in = None
self.id_token = id_token

def setAuthorizeURLs(self, urlObject):
"""Set authorization url using custom values passed in the data dict
:param **data: data dict for custom authorizationURLS
:return: self
"""
if urlObject is not None:
self.auth_endpoint = urlObject['auth_endpoint']
self.token_endpoint = urlObject['token_endpoint']
self.revoke_endpoint = urlObject['revoke_endpoint']
self.user_info_url = urlObject['user_info_url']
return None

def get_authorization_url(self, scopes, state_token=None):
"""Generates authorization url using scopes specified where user is redirected to
Expand Down
1 change: 1 addition & 0 deletions intuitlib/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Scopes(Enum):
PAYROLL = 'com.intuit.quickbooks.payroll'
PAYROLL_TIMETRACKING = 'com.intuit.quickbooks.payroll.timetracking'
PAYROLL_BENEFITS = 'com.intuit.quickbooks.payroll.benefits'
PAYSLIP_READ = 'com.intuit.quickbooks.payroll.payslip.read'

# For migrated apps only
# To not see consent page they should pass the following scopes - openid intuit_name email
Expand Down
13 changes: 7 additions & 6 deletions intuitlib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,22 @@

def get_discovery_doc(environment, session=None):
"""Gets discovery doc based on environment specified.
:param environment: App environment, accepted values: 'sandbox','production','prod','e2e'
:param session: `requests.Session` object if a session is already being used, defaults to None
:return: Discovery doc response
:raises HTTPError: if response status != 200
"""

if environment.lower() in ['production', 'prod']:
discovery_url = DISCOVERY_URL['production']
else:
elif environment.lower() in ['sandbox', 'sand']:
discovery_url = DISCOVERY_URL['sandbox']


response = requests.get(url=discovery_url, headers={'User-Agent': 'Mozilla/5.0'})
else:
discovery_url = environment

if session is not None and isinstance(session, Session):
response = session.get(url=discovery_url)
else:
response = requests.get(url=discovery_url)
if response.status_code != 200:
raise AuthClientError(response)
return response.json()
Expand Down
2 changes: 1 addition & 1 deletion intuitlib/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = '1.2.3'
__version__ = '1.2.4'
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ future>=0.16.0
requests>=2.13.0
mock>=2.0.0
requests_oauthlib>=1.0.0
coverage==4.0.3
coverage==4.4
python-coveralls>=2.9.0
pytest>=3.8.0
pytest-cov==2.5.0
Expand Down
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def test_get_discovery_doc_production(self):
assert discovery_doc['issuer'] == 'https://oauth.platform.intuit.com/op/v1'
assert discovery_doc['userinfo_endpoint'] == 'https://accounts.platform.intuit.com/v1/openid_connect/userinfo'

def test_get_discovery_doc_invalid_input(self):
discovery_doc = get_discovery_doc('random')
def test_get_discovery_doc_custom_url_input(self):
discovery_doc = get_discovery_doc('https://developer.intuit.com/.well-known/openid_sandbox_configuration/')

assert discovery_doc['issuer'] =='https://oauth.platform.intuit.com/op/v1'
assert discovery_doc['userinfo_endpoint'] == 'https://sandbox-accounts.platform.intuit.com/v1/openid_connect/userinfo'
Expand Down

0 comments on commit 6a40386

Please sign in to comment.