@@ -30,137 +30,27 @@ func Init() {
3030		log .Fatal ("error on parsing configuration file" )
3131	}
3232
33+ 	var  providers  []tpmodels.ProviderInput 
34+ 	err  =  config .UnmarshalKey ("Providers" , & providers )
35+ 	if  err  !=  nil  {
36+ 		log .Fatal ("invalid 'Providers' config, " , err )
37+ 	}
38+ 
3339	err  =  supertokens .Init (supertokens.TypeInput {
3440		Supertokens : & supertokens.ConnectionInfo {
35- 			ConnectionURI : "https://try.supertokens.io" ,
41+ 			ConnectionURI : config . GetString ( "SuperTokens.ConnectionURI" ) ,
3642		},
3743		AppInfo : supertokens.AppInfo {
38- 			AppName :       "SuperTokens Demo App" ,
39- 			APIDomain :     "http://localhost"   +   config .GetString ("server.apiPort " ),
40- 			WebsiteDomain : "http://localhost"   +   config .GetString ("server.websitePort " ),
44+ 			AppName :       config . GetString ( "AppInfo.AppName" ) ,
45+ 			APIDomain :     config .GetString ("AppInfo.APIDomain " ),
46+ 			WebsiteDomain : config .GetString ("AppInfo.WebsiteDomain " ),
4147		},
4248		RecipeList : []supertokens.Recipe {
4349			emailverification .Init (evmodels.TypeInput {
4450				Mode : evmodels .ModeRequired ,
4551			}),
4652			thirdpartyemailpassword .Init (& tpepmodels.TypeInput {
47- 				/* 
48- 				   We use different credentials for different platforms when required. For example the redirect URI for Github 
49- 				   is different for Web and mobile. In such a case we can provide multiple providers with different client Ids. 
50- 
51- 				   When the frontend makes a request and wants to use a specific clientId, it needs to send the clientId to use in the 
52- 				   request. In the absence of a clientId in the request the SDK uses the default provider, indicated by `isDefault: true`. 
53- 				   When adding multiple providers for the same type (Google, Github etc), make sure to set `isDefault: true`. 
54- 				*/ 
55- 				Providers : []tpmodels.ProviderInput {
56- 					// We have provided you with development keys which you can use for testsing. 
57- 					// IMPORTANT: Please replace them with your own OAuth keys for production use. 
58- 					{
59- 						Config : tpmodels.ProviderConfig {
60- 							ThirdPartyId : "google" ,
61- 							Clients : []tpmodels.ProviderClientConfig {
62- 								{
63- 									ClientType :   "web" ,
64- 									ClientID :     "1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com" ,
65- 									ClientSecret : "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" ,
66- 								},
67- 								{
68- 									// we use this for mobile apps 
69- 									ClientType :   "mobile" ,
70- 									ClientID :     "1060725074195-c7mgk8p0h27c4428prfuo3lg7ould5o7.apps.googleusercontent.com" ,
71- 									ClientSecret : "" , // this is empty because we follow Authorization code grant flow via PKCE for mobile apps (Google doesn't issue a client secret for mobile apps). 
72- 								},
73- 							},
74- 						},
75- 					},
76- 					{
77- 						Config : tpmodels.ProviderConfig {
78- 							ThirdPartyId : "github" ,
79- 							Clients : []tpmodels.ProviderClientConfig {
80- 								{
81- 									ClientType :   "web" ,
82- 									ClientID :     "467101b197249757c71f" ,
83- 									ClientSecret : "e97051221f4b6426e8fe8d51486396703012f5bd" ,
84- 								},
85- 								{
86- 									// We use this for mobile apps 
87- 									ClientType :   "mobile" ,
88- 									ClientID :     "8a9152860ce869b64c44" ,
89- 									ClientSecret : "00e841f10f288363cd3786b1b1f538f05cfdbda2" ,
90- 								},
91- 							},
92- 						},
93- 					},
94- 					/* 
95- 					   For Apple signin, iOS apps always use the bundle identifier as the client ID when communicating with Apple. Android, Web and other platforms 
96- 					   need to configure a Service ID on the Apple developer dashboard and use that as client ID. 
97- 					   In the example below 4398792-io.supertokens.example.service is the client ID for Web. Android etc and thus we mark it as default. For iOS 
98- 					   the frontend for the demo app sends the clientId in the request which is then used by the SDK. 
99- 					*/ 
100- 					{
101- 						Config : tpmodels.ProviderConfig {
102- 							ThirdPartyId : "apple" ,
103- 							Clients : []tpmodels.ProviderClientConfig {
104- 								{
105- 									// For Android and website apps 
106- 									ClientType : "web" ,
107- 									ClientID :   "4398792-io.supertokens.example.service" ,
108- 									AdditionalConfig : map [string ]interface {}{
109- 										"keyId" :      "7M48Y4RYDL" ,
110- 										"privateKey" : "-----BEGIN PRIVATE KEY-----\n MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n -----END PRIVATE KEY-----" ,
111- 										"teamId" :     "YWQCXGJRJL" ,
112- 									},
113- 								},
114- 								{
115- 									// For iOS Apps 
116- 									ClientType : "ios" ,
117- 									ClientID :   "4398792-io.supertokens.example" ,
118- 									AdditionalConfig : map [string ]interface {}{
119- 										"keyId" :      "7M48Y4RYDL" ,
120- 										"privateKey" : "-----BEGIN PRIVATE KEY-----\n MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n -----END PRIVATE KEY-----" ,
121- 										"teamId" :     "YWQCXGJRJL" ,
122- 									},
123- 								},
124- 							},
125- 						},
126- 					},
127- 					{
128- 						Config : tpmodels.ProviderConfig {
129- 							ThirdPartyId : "discord" ,
130- 							Clients : []tpmodels.ProviderClientConfig {
131- 								{
132- 									ClientType :   "web" ,
133- 									ClientID :     "4398792-907871294886928395" ,
134- 									ClientSecret : "His4yXGEovVp5TZkZhEAt0ZXGh8uOVDm" ,
135- 								},
136- 								{
137- 									// We use this for mobile apps 
138- 									ClientType :   "mobile" ,
139- 									ClientID :     "4398792-907871294886928395" ,
140- 									ClientSecret : "His4yXGEovVp5TZkZhEAt0ZXGh8uOVDm" ,
141- 								},
142- 							},
143- 						},
144- 					},
145- 					{
146- 						Config : tpmodels.ProviderConfig {
147- 							ThirdPartyId : "google-workspaces" ,
148- 							Clients : []tpmodels.ProviderClientConfig {
149- 								{
150- 									ClientType :   "web" ,
151- 									ClientID :     "1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com" ,
152- 									ClientSecret : "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" ,
153- 								},
154- 								{
155- 									// We use this for mobile apps 
156- 									ClientType :   "mobile" ,
157- 									ClientID :     "1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com" ,
158- 									ClientSecret : "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" ,
159- 								},
160- 							},
161- 						},
162- 					},
163- 				},
53+ 				Providers : providers ,
16454			}),
16555			session .Init (nil ),
16656			dashboard .Init (nil ),
0 commit comments