-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_params.go
41 lines (35 loc) · 1.12 KB
/
api_params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
Messaging API v3.4.3
Request params for the Telstra Messaging API
*/
package TelstraMessaging
import "context"
type RequestParams struct {
ContentType string
Accept string
AcceptCharset string
ContentLanguage string
TelstraApiVersion string
GrantType string
Scope string
}
func SetRequestParams() *RequestParams {
return &RequestParams{
ContentType: "application/json",
Accept: "application/json",
AcceptCharset: "utf-8",
ContentLanguage: "en-au",
TelstraApiVersion: "3.1.0",
GrantType: "client_credentials",
Scope: "free-trial-numbers:read free-trial-numbers:write messages:read messages:write virtual-numbers:read virtual-numbers:write reports:read reports:write",
}
}
func GetAuthorization(apiClient *APIClient, clientId string, clientSecret string) (string, error) {
authApi := apiClient.AuthenticationAPI.AuthToken(context.Background(), clientId, clientSecret)
oauthResult, _, err := authApi.AuthToken()
if err != nil {
return "", err
}
accessToken := *oauthResult.AccessToken
return "Bearer " + accessToken, nil
}