oncall-engine/engine/apps/api/views
Joey Orlando 59f727d4f5
Google OAuth2 flow + fetch Google Calendar OOO events (#4067)
# What this PR does

The following is deployed under a feature flag.

**How it works**
1. The user clicks on the "Connect using your Google account" button in
the user profile settings modal
2. The UI makes a call to `GET /api/internal/v1/login/google-oauth2`.
The backend has now been configured to add
`apps.social_auth.backends.GoogleOAuth2` as a "`social_auth` backend".
3. The backend will respond w/ a URL which points to the Google OAuth2
consent screen. The frontend then proceeds by sending the user to this
page. This URL includes the following query parameters (amongst others):
- `redirect_uri` - this will send the user back to
`/api/internal/v1/complete/google-oauth2` (ie. make another API call to
the OnCall backend to finalize the Google OAuth2 flow)
- `state` - this represents an
`apps.auth_token.models.GoogleOAuth2Token` token. This allows us to
identify the OnCall user once they've linked their Google account.
4. Once redirected back to `/api/internal/v1/complete/google-oauth2`,
this will complete the OAuth2 flow. At this point, the backend has
access to several pieces of information about the Google user, including
their `access_token` and `refresh_token`. We persist these (encrypted)
for future use to fetch the user's out-of-office calendar events
5. The response from the API call in 4 above ☝️ is HTTP 302 (redirect)
to `/a/grafana-oncall-app/users/me` (ie. open the user profile settings
modal). At this point the user will see that their account has been
connected and they can further configure the settings

![image](https://github.com/grafana/oncall/assets/9406895/c7673055-8485-4f9a-98df-b4f7347229ce)


## Which issue(s) this PR closes

Closes https://github.com/grafana/oncall-private/issues/2584

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required) - will be done in
https://github.com/grafana/oncall-private/issues/2591
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
show up in the autogenerated release notes. - will be done in
https://github.com/grafana/oncall-private/issues/2591

---------

Co-authored-by: Dominik <dominik.broj@grafana.com>
Co-authored-by: Maxim Mordasov <maxim.mordasov@grafana.com>
2024-04-02 14:59:03 -04:00
..
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
alert_group.py Update alert group state by backsync (#4089) 2024-03-27 12:37:01 +00:00
alert_group_table_settings.py Google OAuth2 flow + fetch Google Calendar OOO events (#4067) 2024-04-02 14:59:03 -04:00
alert_receive_channel.py upgrade flake8 to v7 (#4141) 2024-04-02 14:26:19 +00:00
alert_receive_channel_template.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
alerts.py Add alert detail view (#385) 2022-08-19 14:03:07 +05:00
auth.py Google OAuth2 flow + fetch Google Calendar OOO events (#4067) 2024-04-02 14:59:03 -04:00
channel_filter.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
escalation_chain.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
escalation_policy.py cleanup CustomButton backend code + add ngrok/express outgoing webhook e2e test (#2544) 2024-03-28 15:37:22 +00:00
features.py Google OAuth2 flow + fetch Google Calendar OOO events (#4067) 2024-04-02 14:59:03 -04:00
integration_heartbeat.py Add reset button to disable integration heartbeat (#3959) 2024-03-04 19:20:00 +00:00
labels.py Support prescribed labels (#3848) 2024-02-20 14:42:51 +08:00
live_setting.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
on_call_shifts.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
organization.py Handle None role when syncing users from Grafana (#3147) 2023-10-19 17:39:08 +00:00
paging.py Let mobile use paging endpoint (#3619) 2024-01-08 12:18:39 +00:00
preview_template_options.py Fix of templates api behaviour for public and private api (#1408) 2023-03-01 16:32:15 +08:00
public_api_tokens.py Add RBAC Support (#777) 2022-11-29 09:41:56 +01:00
resolution_note.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
route_regex_debugger.py remove references to AlertGroup.is_archived and AlertGroup.unarchived_objects (#2524) 2023-07-18 11:48:34 +00:00
schedule.py Refactor gaps and empty shift checks (#3785) 2024-01-31 15:25:06 +01:00
shift_swap.py Notify user when their shift swap request is taken (#2992) 2023-09-07 14:59:54 +00:00
slack_channel.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
slack_team_settings.py Handle None role when syncing users from Grafana (#3147) 2023-10-19 17:39:08 +00:00
team.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
telegram_channels.py Support alert routing based on labels (#3778) 2024-01-30 13:07:19 -05:00
user.py Update user details internal API perms (#3900) 2024-02-16 16:48:24 +00:00
user_group.py Handle None role when syncing users from Grafana (#3147) 2023-10-19 17:39:08 +00:00
user_notification_policy.py WIP: Direct paging improvements (#3064) 2023-09-28 03:57:49 +00:00
webhooks.py Add is_from_connected_integration field to webhook model (#3951) 2024-02-23 15:57:57 +00:00