Is it possible to get a cookie from an app? - android

I want to know that , Is it possible that we can access cookies from an app (android) for example - Currently i am logged in , in amazon videos . I want to access cookies (json id) or particularly like this:-
[
{
"domain": ".primevideo.com",
"expirationDate": 2183886856,
"hostOnly": false,
"httpOnly": true,
"name": "at-main-av",
"path": "/",
"sameSite": "no_restriction",
"secure": true,
"session": false,
"storeId": "0",
"value": "Atza|IwEBII7su3R9CsArd2BfylvT5To5LaOLd2gFKOn23APyjsGwk2ieHxH4PXzpHiZSRDXAJJEpRrE-RzYYFFAsLMKthk9ZX3SJ1WEWFzwxPEOhAGZiQO_e5x-sTNRyLbM8cJZZkBX6z738zkb0XLWGUFbY6Ny0Ls0ll9CcpgnhF9DAaHuibw7M9qBGdeNHREkEe2lrqoKu8xk1HbQbjMS59H43okkqRFtifAMmk4HNINlAPwJ7XooorOlZ9Nw48xgzd_m5j4yVz59nFCsUvGh9XF3DJjQidagWXnLTj2zSOYeLNdSu6ChedMo6CdQtXOGJN7vwfQMPT_A0L3KzXt_h38YRn8zDAz-y-r2TEzWV86FxmkZGycI2BeQhYZ6sDEG_7RwRwGpVtd33dCB1C6GMim5cXD4pluwO0BU3-N-kL1VqHP9FhnxFhvKuK4xQi72Mt4_YVcs",
"id": 1
}
]

Related

Integrating PayPal Checkout in an Android app

I am integrating Paypal checkout in an Android App using REST APIs provided by Paypal and my country is India so I am following this guide from PayPal.
How I did as per docs:
Get access-token (/v1/oauth2/token) for further api calls.
Use the Create Order API to create a payment (v2/checkout/orders)and in the response we will get approval url at where you need to redirect user to make the payment.
Now my question is how do I know if payment transaction was successful or not in mobile app because I am using WebView in my app to load approval url.
Order is created like this and I load href inside webview:
{
"id": "1KK44573EX7352015",
"status": "CREATED",
"links": [
{
"href": "https://www.sandbox.paypal.com/checkoutnowtoken=1KK44573EX7352015",
"rel": "approve",
"method": "GET"
}
]
}
I did this way:
As soon as Payment is successfully completed by customer the return_url gets called with query parameters : PayerID & token(orderID). At that time we can update user's payment status in our database (Amount is not deducted yet still because order is yet not approved or captured).
After that we can capture our order (Make sure invoice-id is not duplicate) otherwise status will be not completed.
If order is not approved on the time of capture we get this kind of error:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"issue": "ORDER_NOT_APPROVED",
"description": "Payer has not yet approved the Order for payment. Please redirect the payer to the 'rel':'approve' url returned as part of the HATEOAS links within the Create Order call or provide a valid payment_source in the request."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "47af43e..",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-ORDER_NOT_APPROVED",
"rel": "information_link",
"method": "GET"
}
]
}
If there is duplicate invoice-id you will see error at the time of capture:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"issue": "DUPLICATE_INVOICE_ID",
"description": "Duplicate Invoice ID detected. To avoid a potential duplicate transaction your account setting requires that Invoice Id be unique for each transaction."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "86e0cc7f....",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-DUPLICATE_INVOICE_ID",
"rel": "information_link",
"method": "GET"
}
]
}
If there is currency based issue:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"location": "body",
"issue": "CURRENCY_NOT_SUPPORTED",
"description": "Currency code is not currently supported. Please refer https://developer.paypal.com/docs/integration/direct/rest/currency-codes/ for list of supported currency codes."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "d666b5e5eb0c0",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-CURRENCY_NOT_SUPPORTED",
"rel": "information_link",
"method": "GET"
}
]
}
If your order is successfully captured with status as COMPLETED:
{
"id": "8G0042477K865063U",
"status": "COMPLETED",
"purchase_units": [
{
"reference_id": "default",
"shipping": {
"name": {
"full_name": "John Doe"
},
"address": {
"address_line_1": "10, east street",
"address_line_2": "first building",
"admin_area_2": "Mumbai",
"admin_area_1": "Maharashtra",
"postal_code": "400029",
"country_code": "NZ"
}
},
"payments": {
"captures": [
{
"id": "4K670967VH2547504",
"status": "PENDING",
"status_details": {
"reason": "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION"
},
"amount": {
"currency_code": "NZD",
"value": "170.00"
},
"final_capture": true,
"seller_protection": {
"status": "ELIGIBLE",
"dispute_categories": [
"ITEM_NOT_RECEIVED",
"UNAUTHORIZED_TRANSACTION"
]
},
"invoice_id": "INV-1234567888",
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/4K670967VH2547504",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/4K670967VH2547504/refund",
"rel": "refund",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/8G0042477K865063U",
"rel": "up",
"method": "GET"
}
],
"create_time": "2020-10-31T13:35:58Z",
"update_time": "2020-10-31T13:35:58Z"
}
]
}
}
],
"payer": {
"name": {
"given_name": "Sumit",
"surname": "Shukla"
},
"email_address": "testg32#gmail.com",
"payer_id": "VW87TYSM2GMZ4",
"address": {
"address_line_1": "10, east street",
"admin_area_2": "Mumbai",
"admin_area_1": "Maharashtra",
"postal_code": "400029",
"country_code": "NZ"
}
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/8G0042477K865063U",
"rel": "self",
"method": "GET"
}
]
}
After that you can redirect user to thank you page and update mobile app screen based on database values.

OneDrive for Business account not working with MS Graph SDK

I have implemented access to OneDrive files using the Graph SDK from https://github.com/microsoftgraph/msgraph-sdk-android
For Authentication, I am using the same approach as in the Connect sample which uses the MSAL library, i.e. compile ('com.microsoft.identity.client:msal:0.1.+')in the build.gradle file.
I am calling mPublicClientApp.acquireToken with
String[] scopes = {"offline_access", "https://graph.microsoft.com/Files.ReadWrite","https://graph.microsoft.com/User.Read"}; and successfully retrieve accessTokens for both personal accounts and business accounts.
Next, I want to store a file on the user's OneDrive using
client.getDrive()
.getRoot()
.getItemWithPath("file.txt")
.getContent()
.buildRequest()
.put(data);
which works as expected with a personal account but fails with 403: Forbidden when using my business account (which BTW is the user of the app in the Azure portal). Similarly, I get 404: Not found if I try to get the DriveItem for a file which does exist (and that works for the personal account as well).
Is there anything wrong with my code or does it look like wrong configuration of the app? (I am using the "preview mode" in Azure portal). The permissions I have added are
Files.ReadWrite
Delegiert
Have full access to user files
-
offline_access
Delegiert
Access user's data anytime
-
User.Read
Delegiert
Sign in and read user profile
-
User.ReadWrite
Delegiert
Read and write access to user profile
-
This is my full manifest (with some IDs removed):
{
"id": "...",
"acceptMappedClaims": null,
"accessTokenAcceptedVersion": 2,
"allowPublicClient": true,
"appId": "...",
"appRoles": [],
"oauth2AllowUrlPathMatching": false,
"createdDateTime": "2018-12-24T08:51:51Z",
"groupMembershipClaims": null,
"identifierUris": [
"api://..."
],
"informationalUrls": {
"termsOfService": null,
"support": null,
"privacy": null,
"marketing": null
},
"keyCredentials": [],
"knownClientApplications": [],
"logoUrl": null,
"logoutUrl": null,
"name": "...",
"oauth2AllowIdTokenImplicitFlow": false,
"oauth2AllowImplicitFlow": false,
"oauth2Permissions": [
{
"adminConsentDescription": "blub",
"adminConsentDisplayName": "bla",
"id": "d3659b01-433e-44eb-ab39-9ee9c19f7fe8",
"isEnabled": true,
"lang": null,
"origin": "Application",
"type": "User",
"userConsentDescription": null,
"userConsentDisplayName": "read files",
"value": "Files.ReadWrite"
}
],
"oauth2RequirePostResponse": false,
"optionalClaims": null,
"orgRestrictions": [],
"parentalControlSettings": {
"countriesBlockedForMinors": [],
"legalAgeGroupRule": "Allow"
},
"passwordCredentials": [],
"preAuthorizedApplications": [],
"publisherDomain": "crocoapps.onmicrosoft.com",
"replyUrlsWithType": [
{
"url": "https://login.microsoftonline.com/common/oauth2/nativeclient",
"type": "InstalledClient"
},
{
"url": "msal8374f.................d9b2://auth",
"type": "InstalledClient"
},
{
"url": "https://login.live.com/oauth20_desktop.srf",
"type": "InstalledClient"
}
],
"requiredResourceAccess": [
{
"resourceAppId": "00000003-0000-0000-c000-000000000000",
"resourceAccess": [
{
"id": "7427e0e9-2fba-42fe-b0c0-848c9e6a8182",
"type": "Scope"
},
{
"id": "5c28f0bf-8a70-41f1-8ab2-9032436ddb65",
"type": "Scope"
},
{
"id": "e1fe6dd8-ba31-4d61-89e7-88639da4683d",
"type": "Scope"
},
{
"id": "b4e74841-8e56-480b-be8b-910348b18b4c",
"type": "Scope"
}
]
}
],
"samlMetadataUrl": null,
"signInUrl": null,
"signInAudience": "AzureADandPersonalMicrosoftAccount",
"tags": [],
"tokenEncryptionKeyId": null
}
I think your replyUrlsWithType values aren't holding the correct values. This list should hold the URLs to which Azure AD will redirect to once a token is issued.
Taken from Azure Active Directory app manifest:
replyUrlsWithType
This multi-value property holds the list of registered redirect_uri values that Azure AD will accept as destinations when returning tokens. Each uri value should contain an associated app type value. Supported type values are: Web, InstalledClient.
Hope it helps!

same fql(facebook Query Language) shows different result in graph explorer and embedded in javascript code

I am developing hybrid app using cordova, app is intergated with facebook for which i used android SDK.
I need uid of friends of user, for I am using following fql
SELECT name,uid
FROM user
WHERE uid IN (SELECT target_id
FROM connection
WHERE source_id=me() and is_following=1)
ORDER BY name Asc
which is showing different uid in graph API Explorer and in logcat(android ide)
result in graph API Explorer
{
"data": [
{
"name": "Bharata Dumbo",
"uid": "817899964906568"
},
{
"name": "Deendayal Sharma",
"uid": "807134486015575"
},
{
"name": "Indravadan Intwala",
"uid": "813727452007073"
},
{
"name": "Manisha Parmar",
"uid": "10205158153335480"
},
{
"name": "Nitin Shah",
"uid": "1260451067"
},
{
"name": "Nitin Shah",
"uid": "100005623513169"
},
{
"name": "Smita Vora",
"uid": "323986007788625"
}
]
}
where as result in logcat::
Response getPageLike: `{"data":[{"uid":"100000597166472","name":"Bharata Dumbo"},{"uid":"792885570773800","name":"Deendayal Sharma"},{"uid":"813635845349567","name":"Indravadan Intwala"},{"uid":"10204471863338659","name":"Manisha Parmar"},{"uid":"1260451067","name":"Nitin Shah"},{"uid":"100005623513169","name":"Nitin Shah"},{"uid":"316474181873141","name":"Smita Vora"}]}`
Probably your app is a Graph API >=v2.0 app, that means it uses app-scoped ids instead of global ids as with v1.0.
The Graph Explorer sometimes inherently uses v1.0 (global ids respectively), even if another version is selected from the pulldown.
See
https://developers.facebook.com/docs/apps/changelog#v2_0_graph_api

Obtaining facebook cover photos

How I can get the cover photo of the albums of a user in my application?
Currently, I have a json like this:
"id": "00000",
"albums": {
"data": [
{
"id": "428076573767",
"from": {
"name": "Benjamin",
"id": "00000"
},
"name": "Profile Pictures",
"link": "https://www.facebook.com/album.php?fbid=00000&id=00000&aid=00000",
"cover_photo": "10151465301937683",
"privacy": "everyone",
"count": 57,
"type": "profile",
"created_time": "2010-09-05T08:42:19+0000",
"updated_time": "2013-04-27T23:53:11+0000",
"can_upload": false
},
}
How I can get the cover_photo by URL?
You can get cover photo by adding this into URL. No need to extract cover_photo from Json .
album['id']?>/picture?access_token=12345
// where album is JSON array and access_token is random here..
Try this. It will work.

How to fetch network name from Facebook with Facebook SDK in Android

I want to fetch the Network list and its associated email Address from Facebook in Android. I am using the Facebook SDK for Android. But in response JSON from the Facebook, I am not getting the Network Name and the associated email address. Currently following permission are given.
Utility.mFacebook.authorize(LoginActivity.this,
new String[] { "publish_stream","read_stream", "offline_access","user_education_history", "email" },
Facebook.FORCE_DIALOG_AUTH,
facebookListener.new LoginDialogListener())
UPDATE: From Facebook developer site we can get network name in affiliation here
affiliations - The list of network affiliations, as affiliation elements, each of which contain year, type, status, name, and nid child elements. If no affiliations are returned, this element will be blank. The user's primary network (key: nid) will be listed first.
getting the following response in JSON format, but no affiliation tag in response,
{
"work": [
{
"employer": {
"id": "xxxxxxxxxxxx",
"name": "xyz"
},
"start_date": "0000-00",
"end_date": "0000-00"
}
],
"locale": "en_US",
"link": "http://www.facebook.com/abc.xyz.12",
"education": [
{
"type": "College",
"school": {
"id": "112520115426955",
"name": "University of Pennsylvania"
}
}
],
"updated_time": "2012-11-01T06:31:14+0000",
"id": "0000000000000000",
"first_name": "XYZ",
"timezone": 5.5,
"username": "abc.xyz.12",
"email": "abc#xyz.com",
"verified": true,
"name": "XYZ ABC",
"last_name": "ABC",
"gender": "male"
}
Please let me know, is there any permission required for same. or any other way to get this.
Thanks in Advance!.
This is the FQL query to get an user's affiliation:
select affiliations from user where uid=YOUR_UID_HERE
Example link to graph api explorer with the FQL query below.
https://developers.facebook.com/tools/explorer/?fql=select%20affiliations%20from%20user%20where%20uid%3D1060290170%0A%0A

Categories

Resources