Skip to content

Commit 5346455

Browse files
authored
Google OAuth2 (#33)
1 parent fdc7b9d commit 5346455

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ Although OAuthKit will automatically try to load the `oauth.json` file found ins
134134
## OAuth Providers
135135
* [Github](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps)
136136
* [Google](https://developers.google.com/identity/protocols/oauth2)
137+
* **Important**: When creating a Google OAuth2 application from the [Google API Console](https://console.developers.google.com/) create an OAuth 2.0 Client type of Web Application (not iOS).
137138
* [Instagram](https://developers.facebook.com/docs/instagram-basic-display-api/guides/getting-access-tokens-and-permissions)
138139
* [Microsoft](https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow)
139140
* [Slack](https://api.slack.com/authentication/oauth-v2)

Sources/OAuthKit/OAuth.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ public extension OAuth {
406406
queryItems.append(URLQueryItem(name: "client_secret", value: provider.clientSecret))
407407
queryItems.append(URLQueryItem(name: "code", value: code))
408408
queryItems.append(URLQueryItem(name: "redirect_uri", value: provider.redirectURI))
409+
queryItems.append(URLQueryItem(name: "grant_type", value: "authorization_code"))
409410
urlComponents.queryItems = queryItems
410411
guard let url = urlComponents.url else {
411412
publish(state: .empty)

Tests/OAuthKitTests/Resources/oauth.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,19 @@
1111
"user",
1212
"repo"
1313
]
14+
},
15+
{
16+
"id": "Google",
17+
"authorizationURL": "https://accounts.google.com/o/oauth2/v2/auth",
18+
"accessTokenURL": "https://oauth2.googleapis.com/token",
19+
"clientID": "CLIENT_ID",
20+
"clientSecret": "CLIENT_SECRET",
21+
"redirectURI": "https://github.com/codefiesta/",
22+
"scope": [
23+
"https://www.googleapis.com/auth/userinfo.email",
24+
"https://www.googleapis.com/auth/userinfo.profile",
25+
"openid"
26+
]
1427
}
28+
1529
]

0 commit comments

Comments
 (0)