Skip to content

Commit

Permalink
GetAuthToken
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanganderson committed Mar 27, 2024
1 parent 13d2120 commit eb2a460
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 5 additions & 1 deletion api_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ func (a *AuthenticationAPIService) AuthToken(ctx context.Context) ApiAuthTokenRe
}
}

func (r ApiAuthTokenRequest) AuthToken() (*OAuth, *http.Response, error) {
func (r ApiAuthTokenRequest) GetAuthToken(clientId string, clientSecret string) (*OAuth, *http.Response, error) {
r.clientId = new(string)
*r.clientId = clientId
r.clientSecret = new(string)
*r.clientSecret = clientSecret
return r.Execute()
}

Expand Down
4 changes: 1 addition & 3 deletions api_authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ func Test_TelstraMessaging_AuthenticationAPIService(t *testing.T) {
clientSecret := "YOUR CLIENT SECRET"

authApi := apiClient.AuthenticationAPI.AuthToken(context.Background())
authApi.clientId = &clientId
authApi.clientSecret = &clientSecret

oauthResult, resp, err := authApi.AuthToken()
oauthResult, resp, err := authApi.GetAuthToken(clientId, clientSecret)

if err != nil {
fmt.Println("Error:", err)
Expand Down
5 changes: 1 addition & 4 deletions api_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ func SetRequestParams() *RequestParams {

func GetAuthorization(apiClient *APIClient, clientId string, clientSecret string) (string, error) {
authApi := apiClient.AuthenticationAPI.AuthToken(context.Background())
authApi.clientId = &clientId
authApi.clientSecret = &clientSecret

oauthResult, _, err := authApi.AuthToken()
oauthResult, _, err := authApi.GetAuthToken(clientId, clientSecret)
if err != nil {
return "", err
}
Expand Down

0 comments on commit eb2a460

Please sign in to comment.