11#!/usr/bin/env python
2- # Copyright (C ) 2015, 2018 IBM Corp. All rights reserved.
2+ # Copyright (c ) 2015, 2019 IBM Corp. All rights reserved.
33#
44# Licensed under the Apache License, Version 2.0 (the "License");
55# you may not use this file except in compliance with the License.
@@ -78,6 +78,10 @@ class CouchDB(dict):
7878 IAM authentication with server. Default is False.
7979 Use :func:`~cloudant.client.CouchDB.iam` to construct an IAM
8080 authenticated client.
81+ :param string iam_client_id: Keyword argument, client ID to use when
82+ authenticating with the IAM token server. Default is ``None``.
83+ :param string iam_client_secret: Keyword argument, client secret to use when
84+ authenticating with the IAM token server. Default is ``None``.
8185 """
8286 _DATABASE_CLASS = CouchDatabase
8387
@@ -95,6 +99,8 @@ def __init__(self, user, auth_token, admin_party=False, **kwargs):
9599 self ._auto_renew = kwargs .get ('auto_renew' , False )
96100 self ._use_basic_auth = kwargs .get ('use_basic_auth' , False )
97101 self ._use_iam = kwargs .get ('use_iam' , False )
102+ self ._iam_client_id = kwargs .get ('iam_client_id' , None )
103+ self ._iam_client_secret = kwargs .get ('iam_client_secret' , None )
98104 # If user/pass exist in URL, remove and set variables
99105 if not self ._use_basic_auth and self .server_url :
100106 parsed_url = url_parse (kwargs .get ('url' ))
@@ -162,6 +168,8 @@ def connect(self):
162168 self ._auth_token ,
163169 self .server_url ,
164170 auto_renew = self ._auto_renew ,
171+ client_id = self ._iam_client_id ,
172+ client_secret = self ._iam_client_secret ,
165173 timeout = self ._timeout
166174 )
167175 else :
@@ -844,7 +852,8 @@ def bluemix(cls, vcap_services, instance_name=None, service_name=None, **kwargs)
844852 if hasattr (service , 'iam_api_key' ):
845853 return Cloudant .iam (service .username ,
846854 service .iam_api_key ,
847- url = service .url )
855+ url = service .url ,
856+ ** kwargs )
848857 return Cloudant (service .username ,
849858 service .password ,
850859 url = service .url ,
0 commit comments