AuthenticatedClient#

class AuthenticatedClient[source]#

A Client which has been authenticated for use on secured endpoints

Methods

get

Get an AuthenticatedClient by logging in with your username and password.

get_from_cli

Get an AuthenticatedClient by logging in through command line interface.

get_with_token

Get an AuthenticatedClient by logging with an access token.

Attributes

about

Get a AboutService to do requests concerning About.

assignment

Get a AssignmentService to do requests concerning Assignment.

auto_test

Get a AutoTestService to do requests concerning AutoTest.

comment

Get a CommentService to do requests concerning Comment.

course

Get a CourseService to do requests concerning Course.

course_price

Get a CoursePriceService to do requests concerning CoursePrice.

file

Get a FileService to do requests concerning File.

git_provider

Get a GitProviderService to do requests concerning GitProvider.

group

Get a GroupService to do requests concerning Group.

login_link

Get a LoginLinkService to do requests concerning LoginLink.

lti

Get a LTIService to do requests concerning LTI.

oauth_provider

Get a OAuthProviderService to do requests concerning OAuthProvider.

permission

Get a PermissionService to do requests concerning Permission.

site_settings

Get a SiteSettingsService to do requests concerning SiteSettings.

snippet

Get a SnippetService to do requests concerning Snippet.

submission

Get a SubmissionService to do requests concerning Submission.

task_result

Get a TaskResultService to do requests concerning TaskResult.

tenant

Get a TenantService to do requests concerning Tenant.

transaction

Get a TransactionService to do requests concerning Transaction.

user

Get a UserService to do requests concerning User.

user_setting

Get a UserSettingService to do requests concerning UserSetting.

classmethod get(username, password, tenant=None, host='https://app.codegra.de')[source]#

Get an AuthenticatedClient by logging in with your username and password.

with AuthenticatedClient.get(
    username='my-username',
    password=os.getenv('CG_PASS'),
    tenant='My University',
) as client:
    print('Hi I am {}'.format(client.user.get().name)
Parameters:
  • username (str) – Your CodeGrade username.

  • password (str) – Your CodeGrade password, if you do not know your password you can set it by following these steps.

  • tenant (Optional[str]) – The id or name of your tenant in CodeGrade. This is the name you click on the login screen.

  • host (str) – The CodeGrade instance you want to use.

Returns:

A client that you can use to do authenticated requests to CodeGrade. We advise you to use it in combination with a with block (i.e. as a contextmanager) for the highest efficiency.

Return type:

AuthenticatedClient

classmethod get_with_token(token, host='https://app.codegra.de', *, check=True)[source]#

Get an AuthenticatedClient by logging with an access token.

Parameters:
  • token (str) – The access token you want to use to login.

  • host (str) – The CodeGrade instance you want to login to.

  • check (bool) – If False we won’t check if your token actually works.

Returns:

A new AuthenticatedClient.

Return type:

AuthenticatedClient

classmethod get_from_cli()[source]#

Get an AuthenticatedClient by logging in through command line interface.

Returns:

A new AuthenticatedClient.

Return type:

AuthenticatedClient