-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 1e3b357 Author: Martin Rode <martin.rode@programmfabrik.de> Date: Thu Jul 1 14:23:16 2021 +0200 body_type: fixed "urlencoded" urlencoded was not working if the provided body did not unmarshal to map[string][string] but to map[string]interface{}, which must have always happened. So, I suspect this never worked and is untested in the unit tests. commit 8458072 Author: Martin Rode <martin.rode@programmfabrik.de> Date: Thu Jul 1 14:22:07 2021 +0200 oauth2: added "oauth2_basic_auth" + improved template functions Renamed oauth2.Key to oauth2.Client commit 8dc7114 Author: Unai Garcia <unai.garcia@programmfabrik.de> Date: Thu Jul 1 12:02:54 2021 +0200 returning only string on template functions commit 929b37f Author: Unai Garcia <unai.garcia@programmfabrik.de> Date: Thu Jul 1 11:06:16 2021 +0200 added template functions, tests and doc commit ca1a69b Merge: ee59ffb f4c6a99 Author: Unai Garcia <unai.garcia@programmfabrik.de> Date: Thu Jul 1 09:52:22 2021 +0200 Merge branch 'master' into enhancement/oauth2-flows commit ee59ffb Author: Martin Rode <martin.rode@programmfabrik.de> Date: Thu Jul 1 09:47:20 2021 +0200 oauth2: changed error management commit c21f01e Author: Martin Rode <martin.rode@programmfabrik.de> Date: Wed Jun 30 17:14:22 2021 +0200 oauth2: renamed oauth2_token, fixed README typos commit f361cab Author: Unai Garcia <unai.garcia@programmfabrik.de> Date: Fri Jun 25 16:10:40 2021 +0200 added some doc about oauth functionality commit 385747e Author: Unai Garcia <unai.garcia@programmfabrik.de> Date: Fri Jun 25 15:44:36 2021 +0200 - Added support for oauth different flows - Added template functions for each - Added unit and api tests
- Loading branch information
1 parent
f4c6a99
commit 39c5e73
Showing
15 changed files
with
242 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package template | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"golang.org/x/oauth2" | ||
) | ||
|
||
type oAuth2TokenExtended struct { | ||
*oauth2.Token | ||
Error string `json:"error"` | ||
ErrorDescription string `json:"error_description"` | ||
} | ||
|
||
// ReadOAuthReturnValue checks the return values from an OAUTH client and | ||
// stores the error in an extended struct of the oAuth token | ||
func readOAuthReturnValue(t *oauth2.Token, err error) (tE oAuth2TokenExtended, err2 error) { | ||
if t == nil { | ||
t = &oauth2.Token{} // Make sure we have "AccessToken" in our struct | ||
} | ||
tE = oAuth2TokenExtended{Token: t} | ||
if err != nil { | ||
switch v := err.(type) { | ||
case *oauth2.RetrieveError: | ||
err = json.Unmarshal(v.Body, &tE) | ||
if err != nil { | ||
tE.Error = err.Error() | ||
tE.ErrorDescription = string(v.Body) | ||
err = nil | ||
} | ||
} | ||
} | ||
return tE, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.