belvo.resources.widget_token
1from typing import Any, Dict, Optional 2 3from belvo.resources.base import Resource 4 5 6class WidgetToken(Resource): 7 endpoint = "/api/token/" 8 9 def create( 10 self, 11 *, 12 scopes: Optional[str] = None, 13 link: Optional[str] = None, 14 widget: Optional[Dict[str, Any]] = None, 15 raise_exception: bool = False, 16 ): 17 """Create a widget access token 18 19 Args: 20 scopes (Optional[str], optional): The scope of data to retrieve. We automatically default to`read_institutions, write_linkss`. 21 link (Optional[str], optional): The `link_id` you want to update credentials for. For more information, see our [Connect Widget in Update Mode](https://developers.belvo.com/docs/connect-widget-update-mode) devportal article. Defaults to None. 22 widget (Optional[Dict[str, Any]], optional): Optional object where you can provide custom branding. For more information, see our [Branding and customization](https://developers.belvo.com/docs/widget-branding-and-customization) devportal article. Defaults to None. 23 raise_exception (bool, optional): Indicates whether to raise an exception or return the API error. Defaults to `False`. 24 25 Returns: 26 Your widget access token. 27 """ 28 if scopes is None: 29 scopes = "read_institutions,write_links" 30 31 data: Dict[str, Any] = { 32 "id": self.session._secret_key_id, 33 "password": self.session._secret_key_password, 34 "scopes": scopes, 35 } 36 37 if link: 38 data.update(link_id=link) 39 40 if widget: 41 data.update(widget=widget) 42 43 return self.session.post(self.endpoint, data=data, raise_exception=raise_exception)
7class WidgetToken(Resource): 8 endpoint = "/api/token/" 9 10 def create( 11 self, 12 *, 13 scopes: Optional[str] = None, 14 link: Optional[str] = None, 15 widget: Optional[Dict[str, Any]] = None, 16 raise_exception: bool = False, 17 ): 18 """Create a widget access token 19 20 Args: 21 scopes (Optional[str], optional): The scope of data to retrieve. We automatically default to`read_institutions, write_linkss`. 22 link (Optional[str], optional): The `link_id` you want to update credentials for. For more information, see our [Connect Widget in Update Mode](https://developers.belvo.com/docs/connect-widget-update-mode) devportal article. Defaults to None. 23 widget (Optional[Dict[str, Any]], optional): Optional object where you can provide custom branding. For more information, see our [Branding and customization](https://developers.belvo.com/docs/widget-branding-and-customization) devportal article. Defaults to None. 24 raise_exception (bool, optional): Indicates whether to raise an exception or return the API error. Defaults to `False`. 25 26 Returns: 27 Your widget access token. 28 """ 29 if scopes is None: 30 scopes = "read_institutions,write_links" 31 32 data: Dict[str, Any] = { 33 "id": self.session._secret_key_id, 34 "password": self.session._secret_key_password, 35 "scopes": scopes, 36 } 37 38 if link: 39 data.update(link_id=link) 40 41 if widget: 42 data.update(widget=widget) 43 44 return self.session.post(self.endpoint, data=data, raise_exception=raise_exception)
def
create( self, *, scopes: Optional[str] = None, link: Optional[str] = None, widget: Optional[Dict[str, Any]] = None, raise_exception: bool = False):
10 def create( 11 self, 12 *, 13 scopes: Optional[str] = None, 14 link: Optional[str] = None, 15 widget: Optional[Dict[str, Any]] = None, 16 raise_exception: bool = False, 17 ): 18 """Create a widget access token 19 20 Args: 21 scopes (Optional[str], optional): The scope of data to retrieve. We automatically default to`read_institutions, write_linkss`. 22 link (Optional[str], optional): The `link_id` you want to update credentials for. For more information, see our [Connect Widget in Update Mode](https://developers.belvo.com/docs/connect-widget-update-mode) devportal article. Defaults to None. 23 widget (Optional[Dict[str, Any]], optional): Optional object where you can provide custom branding. For more information, see our [Branding and customization](https://developers.belvo.com/docs/widget-branding-and-customization) devportal article. Defaults to None. 24 raise_exception (bool, optional): Indicates whether to raise an exception or return the API error. Defaults to `False`. 25 26 Returns: 27 Your widget access token. 28 """ 29 if scopes is None: 30 scopes = "read_institutions,write_links" 31 32 data: Dict[str, Any] = { 33 "id": self.session._secret_key_id, 34 "password": self.session._secret_key_password, 35 "scopes": scopes, 36 } 37 38 if link: 39 data.update(link_id=link) 40 41 if widget: 42 data.update(widget=widget) 43 44 return self.session.post(self.endpoint, data=data, raise_exception=raise_exception)
Create a widget access token
Arguments:
- scopes (Optional[str], optional): The scope of data to retrieve. We automatically default to
read_institutions, write_linkss
. - link (Optional[str], optional): The
link_id
you want to update credentials for. For more information, see our Connect Widget in Update Mode devportal article. Defaults to None. - widget (Optional[Dict[str, Any]], optional): Optional object where you can provide custom branding. For more information, see our Branding and customization devportal article. Defaults to None.
- raise_exception (bool, optional): Indicates whether to raise an exception or return the API error. Defaults to
False
.
Returns:
Your widget access token.