code: def check_auth(args):
      
      oauth2_instance = oauth2.build_oauth2(args.app, args)
      auth = oauth2_instance.build_authorizer()
      my_profile_url = (
          'https://api.coursera.org/api/externalBasicProfiles.v1?'
          'q=me&fields=name'
      )
      r = requests.get(my_profile_url, auth=auth)
      if r.status_code != 200:
          logging.error('Received response code %s from the basic profile API.',
                        r.status_code)
          logging.debug('Response body:\n%s', r.text)
          sys.exit(1)
      try:
          external_id = r.json()['elements'][0]['id']
      except:
          logging.error(
              'Could not parse the external id out of the response body %s',
              r.text)
          external_id = None
  
      try:
          name = r.json()['elements'][0]['name']
      except:
          logging.error(
              'Could not parse the name out of the response body %s',
              r.text)
          name = None
  
      if not args.quiet > 0:
          print 'Name: %s' % name
          print 'External ID: %s' % external_id
  
      if name is None or external_id is None:
          sys.exit(1)
docs: Checks courseraoauth2client's connectivity to the coursera.org API servers
      for a specific application