د Google Drive چینل اضافه کول
مخکې څه ته اړتیا لرئ
له پیل مخکې دا شیان برابر کړئ:
| اړتیا | ولې ورته اړتیا ده |
|---|---|
| Google حساب | Google Cloud ته د لاسرسي او Google Drive د authorize کولو لپاره |
| Google Cloud پروژه | د Drive API فعالولو او OAuth اعتبارلیکونه جوړولو لپاره |
| OAuth 2.0 client | ImgHost یې د Client ID، Client Secret او Refresh Token اخیستلو لپاره کاروي |
| ستاسو ImgHost ډومېن | د OAuth ریډایرکټ URI لپاره کارېږي. دا باید له هغه ډومېن سره برابر وي چې تاسې یې رښتیا کاروئ. |
د تنظیم پړاوونه
1 ګام: Google Drive API فعال کړئ
- Google Cloud Console پرانیزئ.
- نوی پروژه جوړ کړئ یا موجود پروژه وټاکئ.
APIs & Servicesته لاړ شئ.Enable APIs and Servicesکلیک کړئ.Google Drive APIولټوئ.- پاڼه یې پرانیزئ او enable کلیک کړئ.
2 ګام: د OAuth Consent Screen تنظیم کړئ
- په Google Cloud کې
Google Auth Platformپرانیزئ. - د
Brandingبنسټیز معلومات بشپړ کړئ، لکه اپ name، support email او developer contact email. Audienceپرانیزئ.- د ډېرو self-hosted شخصي نصبونو لپاره
Externalمناسب دی. - که
Externalمو وټاکه، هغه Google حساب چې authorize کوئ دTest usersلاندې اضافه کړئ. Data Accessپرانیزئ.- د Google Drive اړین permissions اضافه کړئ.
3 ګام: OAuth 2.0 Client جوړ کړئ
- په
Google Auth PlatformکېClientsپرانیزئ. - نوی client جوړ کړئ.
- د اپlication type په توګه
Web applicationوټاکئ. - داسې نوم ورکړئ چې وروسته یې وپېژنئ.
- د authorized JavaScript origins لپاره خپل ImgHost URL ولیکئ، د بېلګې په توګه:
text
https://img.example.com- د authorized ریډایرکټ URIs لپاره ولیکئ:
text
https://img.example.com/api/oauth/google/callback

کله چې client جوړ شو، دا ارزښتونه کاپي کړئ:
| Generated ارزښت | د ImgHost فیلډ |
|---|---|
| Client ID | Client ID |
| Client Secret | Client Secret |
4 ګام: د Google Drive چینل ډک کړئ
په د اپلوډ تنظیمات کې Google Drive وټاکئ او دا fields ډک کړئ:
| د ImgHost فیلډ | څه ولیکئ |
|---|---|
| د چینل نوم | داسې نوم چې وپېژندل شي، لکه Main Google Drive |
| Client ID | له Google Cloud څخه اخیستل شوی Client ID |
| Client Secret | له Google Cloud څخه اخیستل شوی Client Secret |
| Refresh ټوکن | اوس یې تش پرېږدئ. په بل ګام کې یې اخلئ. |
| اصلي ډایرکټري | اختیاري. اصلي یې imgbed دی. |

5 ګام: Refresh ټوکن واخلئ
Get Tokenکلیک کړئ.- هغه Google حساب وټاکئ چې نښلول یې غواړئ.
- د authorization پیغامونه بشپړ کړئ.
- کالبک page به
Refresh Tokenښکاره کړي. - هغه کاپي کړئ.
- بېرته ImgHost ته راشئ او د
Refresh Tokenفیلډ کې یې پیسټ کړئ.

که وروسته Google حساب بدل کړئ، OAuth client بدل کړئ، یا پخوانی authorization expire شي، چینل ړنګولو ته اړتیا نشته. د edit پاڼه پرانیزئ او Reauthorize کلیک کړئ.
6 ګام: چینل خوندي کړئ
کله چې ټول fields ډک شول، چینل خوندي کړئ.
چټک بهیر
text
Open Google Cloud
-> Create or select a project
-> Enable Google Drive API
-> Configure Google Auth Platform
-> If Audience is External, add your Google account to Test users
-> Create a Web application OAuth client
-> Use https://your-domain.com/api/oauth/google/callback as the redirect URI
-> Fill Client ID and Client Secret into ImgHost
-> Click Get Token
-> Sign in with Google and authorize
-> Copy the Refresh Token from the callback page
-> Paste it back into ImgHost and save
-> Upload a test imageماخذونه
- Google OAuth Web سرور اپlications: https://developers.google.com/identity/protocols/oauth2/web-server
- Google Workspace OAuth Consent تنظیمات: https://developers.google.com/workspace/guides/configure-oauth-consent
- Google Drive API Auth Scopes: https://developers.google.com/workspace/drive/api/guides/api-specific-auth