def _get_application_default_credential_from_file(filename):
<EOL>with open(filename) as file_obj:<EOL><INDENT>client_credentials = json.load(file_obj)<EOL><DEDENT>credentials_type = client_credentials.get('<STR_LIT:type>')<EOL>if credentials_type == AUTHORIZED_USER:<EOL><INDENT>required_fields = set(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL><DEDENT>elif credentials_type == SERVICE_ACCOUNT:<EOL><INDENT>required_fields = set(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>raise ApplicationDefaultCredentialsError(<EOL>"<STR_LIT>" +<EOL>AUTHORIZED_USER + "<STR_LIT>" + SERVICE_ACCOUNT + "<STR_LIT>")<EOL><DEDENT>missing_fields = required_fields.difference(client_credentials.keys())<EOL>if missing_fields:<EOL><INDENT>_raise_exception_for_missing_fields(missing_fields)<EOL><DEDENT>if client_credentials['<STR_LIT:type>'] == AUTHORIZED_USER:<EOL><INDENT>return GoogleCredentials(<EOL>access_token=None,<EOL>client_id=client_credentials['<STR_LIT>'],<EOL>client_secret=client_credentials['<STR_LIT>'],<EOL>refresh_token=client_credentials['<STR_LIT>'],<EOL>token_expiry=None,<EOL>token_uri=oauth2client.GOOGLE_TOKEN_URI,<EOL>user_agent='<STR_LIT>')<EOL><DEDENT>else:  <EOL><INDENT>from oauth2client import service_account<EOL>return service_account._JWTAccessCredentials.from_json_keyfile_dict(<EOL>client_credentials)<EOL><DEDENT>
Build the Application Default Credentials from file.