This repository has been archived by the owner on Sep 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add POST /sso and allow Captcha token to be specified
- Loading branch information
1 parent
9b06acb
commit 5662c9d
Showing
6 changed files
with
126 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package endpoints | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"net/http" | ||
|
||
"github.com/kwoodhouse93/gotrue-go/types" | ||
) | ||
|
||
const ssoPath = "/sso" | ||
|
||
// POST /sso | ||
// | ||
// Initiate an SSO session with the given provider. | ||
// | ||
// If successful, the server returns a redirect to the provider's authorization | ||
// URL. The client will follow it and return the final response. Should you | ||
// prefer the client not to follow redirects, you can provide a custom HTTP | ||
// client using WithClient(). See the example below. | ||
// | ||
// Example: | ||
// c := http.Client{ | ||
// CheckRedirect: func(req *http.Request, via []*http.Request) error { | ||
// return http.ErrUseLastResponse | ||
// }, | ||
// } | ||
func (c *Client) SSO(req types.SSORequest) (*http.Response, error) { | ||
body, err := json.Marshal(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
r, err := c.newRequest(http.MethodPost, ssoPath, bytes.NewBuffer(body)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return c.client.Do(r) | ||
} |
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,9 @@ | ||
package types | ||
|
||
type SecurityEmbed struct { | ||
Security GoTrueMetaSecurity `json:"gotrue_meta_security"` | ||
} | ||
|
||
type GoTrueMetaSecurity struct { | ||
CaptchaToken string `json:"captcha_token"` | ||
} |