github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/doc/third-party-access.md (about) 1 # Accessing QuickFeed with Third-party Applications 2 3 ## Creating a QuickFeed User 4 5 First you will have to create a user on QuickFeed if you do not already have one. 6 You can do this by logging in to QuickFeed with your GitHub account. 7 Your application will be granted the same access permissions as your user. 8 9 ## Creating a Personal Access Token 10 11 To access QuickFeed with your application you need will need to create a GitHub personal access token. 12 You need to use the same GitHub account as the one you used to create your QuickFeed user. 13 You can create a personal access token by following the instructions [here](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). 14 You can use either a [classic personal access token](https://github.com/settings/tokens/new), or a [fine-grained personal access token](https://github.com/settings/personal-access-tokens/new). 15 16 The token you create should **not** have any permissions granted. 17 QuickFeed will only use the token to identify you. 18 19 The personal access token serves as your credentials for accessing QuickFeed. 20 21 ## Usage 22 23 For your application to be granted access to QuickFeed you need to provide the personal access token in the `Authorization` header of your requests. 24 The token needs to be sent with every request you send to QuickFeed. 25 26 Example curl request: 27 28 ```bash 29 curl \ 30 --header 'Content-Type: application/json' \ 31 --header 'Authorization: <TOKEN>' \ 32 --data '{}' \ 33 <https://<YOUR QUICKFEED DOMAIN>/qf.QuickFeedService/GetUser> 34 ``` 35 36 This should return a response similar to this: 37 38 ```bash 39 { 40 "ID":"1", 41 "Name":"Test User", 42 "StudentID":"123456", 43 "Email":"test.user@example.com", 44 "AvatarURL":"https://example.com/avatar.png", 45 "Login":"TestUser", 46 } 47 ``` 48 49 ## Using the QuickFeedService API 50 51 The `QuickFeedService` API is defined in [qf.proto](../qf/quickfeed.proto). 52 To use the API you need to write a client for your language of choice. 53 To invoke one of the API methods you need to add the `Authorization` header to your request. 54 This can be done using a token auth client interceptor, as shown in the following Go example: 55 56 ```go 57 func NewQuickFeed(serverURL, token string) qfconnect.QuickFeedServiceClient { 58 return qfconnect.NewQuickFeedServiceClient( 59 http.DefaultClient, 60 serverURL, 61 connect.WithInterceptors( 62 interceptor.NewTokenAuthClientInterceptor(token), 63 ), 64 ) 65 } 66 ``` 67 68 See also the [approvelist](../cmd/approvelist/main.go) command for an example of how to use the API.