I think we can clean this up with get:

    if 'scopes' in service.get('auth', {}).get('oauth2', {}):